On 2014-11-05 00:26, Peter Meerwald wrote:
From: Peter Meerwald <[email protected]>
Signed-off-by: Peter Meerwald <[email protected]>
---
src/pulsecore/tagstruct.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/pulsecore/tagstruct.c b/src/pulsecore/tagstruct.c
index a504be8..f27d313 100644
--- a/src/pulsecore/tagstruct.c
+++ b/src/pulsecore/tagstruct.c
@@ -37,6 +37,7 @@
#include <pulsecore/socket.h>
#include <pulsecore/macro.h>
+#include <pulsecore/flist.h>
#include "tagstruct.h"
@@ -59,10 +60,13 @@ struct pa_tagstruct {
} per_type;
};
+PA_STATIC_FLIST_DECLARE(tagstructs, 0, pa_xfree);
+
pa_tagstruct *pa_tagstruct_new(void) {
pa_tagstruct*t;
- t = pa_xnew(pa_tagstruct, 1);
+ if (!(t = pa_flist_pop(PA_STATIC_FLIST_GET(tagstructs))))
+ t = pa_xnew(pa_tagstruct, 1);
t->data = t->per_type.appended;
t->allocated = MAX_APPENDED_SIZE;
t->length = t->rindex = 0;
@@ -76,7 +80,8 @@ pa_tagstruct *pa_tagstruct_new_fixed(const uint8_t* data,
size_t length) {
pa_assert(data && length);
- t = pa_xnew(pa_tagstruct, 1);
+ if (!(t = pa_flist_pop(PA_STATIC_FLIST_GET(tagstructs))))
+ t = pa_xnew(pa_tagstruct, 1); t->data = t->per_type.appended;
Two statements on the same line here.
Otherwise, patches 1, 2, 3, 4 and 5 look good.
t->data = (uint8_t*) data;
t->allocated = t->length = length;
t->rindex = 0;
@@ -90,7 +95,8 @@ void pa_tagstruct_free(pa_tagstruct*t) {
if (t->type == PA_TAGSTRUCT_DYNAMIC)
pa_xfree(t->data);
- pa_xfree(t);
+ if (pa_flist_push(PA_STATIC_FLIST_GET(tagstructs), t) < 0)
+ pa_xfree(t);
}
static void extend(pa_tagstruct*t, size_t l) {
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
_______________________________________________
pulseaudio-discuss mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss