]> code.delx.au - pulseaudio/commitdiff
core: Change sematics of pa_flist_new_with_name() (v1.1)
authorJyri Sarha <jyri.sarha@nokia.com>
Thu, 13 Jan 2011 14:44:41 +0000 (16:44 +0200)
committerColin Guthrie <cguthrie@mandriva.org>
Sat, 15 Jan 2011 13:22:13 +0000 (13:22 +0000)
Name string is copied and added to flist structure. The original is
responsibility of the caller. The name is only used for debug printing.

src/pulsecore/flist.c
src/pulsecore/flist.h

index 1867525bbbe71c4e1633b157bf32e19d96898f43..23af5dd4cd8e41470004a30b3c1c444d44e3391e 100644 (file)
@@ -83,13 +83,14 @@ static void stack_push(pa_atomic_ptr_t *list, pa_flist_elem *new_elem) {
 pa_flist *pa_flist_new_with_name(unsigned size, const char *name) {
     pa_flist *l;
     unsigned i;
+    pa_assert(name);
 
     if (!size)
         size = FLIST_SIZE;
 
     l = pa_xmalloc0(sizeof(pa_flist) + sizeof(pa_flist_elem) * size);
 
-    l->name = name;
+    l->name = pa_xstrdup(name);
     l->size = size;
     pa_atomic_ptr_store(&l->stored, NULL);
     pa_atomic_ptr_store(&l->empty, NULL);
@@ -105,6 +106,7 @@ pa_flist *pa_flist_new(unsigned size) {
 
 void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb) {
     pa_assert(l);
+    pa_assert(l->name);
 
     if (free_cb) {
         pa_flist_elem *elem;
index 7fb50359034784aa57bb00f93344588a3147a766..915b113511418d9739b2d83e33854415bae6a306 100644 (file)
@@ -33,8 +33,8 @@
 typedef struct pa_flist pa_flist;
 
 pa_flist * pa_flist_new(unsigned size);
-/* Freeing the name is responsibility of caller. The name is only used
- * for debug printing. */
+/* Name string is copied and added to flist structure. The original is
+ * responsibility of the caller. The name is only used for debug printing. */
 pa_flist * pa_flist_new_with_name(unsigned size, const char *name);
 void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb);