1
From 21dee4b1b96e100d77ab9412c721e3b410e570b2 Mon Sep 17 00:00:00 2001
2
From: Wim Taymans <wim.taymans@gmail.com>
3
Date: Tue, 7 Apr 2015 17:13:13 +0200
4
Subject: [PATCH 1/5] tagstruct: add copy method
6
Add a method to copy a tagstruct. This will also reset the read pointer
9
src/pulsecore/tagstruct.c | 13 +++++++++++++
10
src/pulsecore/tagstruct.h | 2 ++
11
2 files changed, 15 insertions(+)
13
diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
14
index 8a29957..c29e49b 100644
15
--- a/src/pulsecore/tagstruct.c
16
+++ b/src/pulsecore/tagstruct.c
17
@@ -97,6 +97,19 @@ void pa_tagstruct_free(pa_tagstruct*t) {
21
+pa_tagstruct *pa_tagstruct_copy(pa_tagstruct*t) {
24
+ if (!(tc = pa_flist_pop(PA_STATIC_FLIST_GET(tagstructs))))
25
+ tc = pa_xnew(pa_tagstruct, 1);
26
+ tc->data = pa_xmemdup(t->data, t->length);
27
+ tc->allocated = t->length;
29
+ tc->type = PA_TAGSTRUCT_DYNAMIC;
34
static inline void extend(pa_tagstruct*t, size_t l) {
36
pa_assert(t->type != PA_TAGSTRUCT_FIXED);
37
diff --git a/src/pulsecore/tagstruct.h b/src/pulsecore/tagstruct.h
38
index 348c65d..e648d75 100644
39
--- a/src/pulsecore/tagstruct.h
40
+++ b/src/pulsecore/tagstruct.h
41
@@ -64,6 +64,8 @@ pa_tagstruct *pa_tagstruct_new(void);
42
pa_tagstruct *pa_tagstruct_new_fixed(const uint8_t* data, size_t length);
43
void pa_tagstruct_free(pa_tagstruct*t);
45
+pa_tagstruct *pa_tagstruct_copy(pa_tagstruct*t);
47
int pa_tagstruct_eof(pa_tagstruct*t);
48
const uint8_t* pa_tagstruct_data(pa_tagstruct*t, size_t *l);