From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx> pa_tagstruct_free_data() is used in only one place to pass data from a tagstruct to a packet this patch is a temporary solution which introduces an extra malloc(); will be resolved shortly... Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net> --- src/pulsecore/pstream-util.c | 9 ++++++--- src/pulsecore/tagstruct.c | 13 ------------- src/pulsecore/tagstruct.h | 1 - 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/pulsecore/pstream-util.c b/src/pulsecore/pstream-util.c index 19d7e49..4b93b86 100644 --- a/src/pulsecore/pstream-util.c +++ b/src/pulsecore/pstream-util.c @@ -25,19 +25,22 @@ #include <pulsecore/native-common.h> #include <pulsecore/macro.h> +#include <pulse/xmalloc.h> #include "pstream-util.h" static void pa_pstream_send_tagstruct_with_ancil_data(pa_pstream *p, pa_tagstruct *t, const pa_cmsg_ancil_data *ancil_data) { size_t length; - uint8_t *data; + const uint8_t *data; pa_packet *packet; pa_assert(p); pa_assert(t); - pa_assert_se(data = pa_tagstruct_free_data(t, &length)); - pa_assert_se(packet = pa_packet_new_dynamic(data, length)); + pa_assert_se(data = pa_tagstruct_data(t, &length)); + pa_assert_se(packet = pa_packet_new_dynamic(pa_xmemdup(data, length), length)); + pa_tagstruct_free(t); + pa_pstream_send_packet(p, packet, ancil_data); pa_packet_unref(packet); } diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c index f737291..834a972 100644 --- a/src/pulsecore/tagstruct.c +++ b/src/pulsecore/tagstruct.c @@ -87,19 +87,6 @@ void pa_tagstruct_free(pa_tagstruct*t) { pa_xfree(t); } -uint8_t* pa_tagstruct_free_data(pa_tagstruct*t, size_t *l) { - uint8_t *p; - - pa_assert(t); - pa_assert(t->type == PA_TAGSTRUCT_DYNAMIC); - pa_assert(l); - - p = t->data; - *l = t->length; - pa_xfree(t); - return p; -} - static void extend(pa_tagstruct*t, size_t l) { pa_assert(t); pa_assert(t->type != PA_TAGSTRUCT_FIXED); diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h index 860332d..6a4a0cd 100644 --- a/src/pulsecore/tagstruct.h +++ b/src/pulsecore/tagstruct.h @@ -65,7 +65,6 @@ enum { pa_tagstruct *pa_tagstruct_new(void); pa_tagstruct *pa_tagstruct_new_fixed(const uint8_t* data, size_t length); void pa_tagstruct_free(pa_tagstruct*t); -uint8_t* pa_tagstruct_free_data(pa_tagstruct*t, size_t *l); int pa_tagstruct_eof(pa_tagstruct*t); const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l); -- 1.9.1