[pulseaudio-commits] r2058 - /trunk/src/pulse/operation.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Nov 14 08:11:10 PST 2007


Author: lennart
Date: Wed Nov 14 17:11:09 2007
New Revision: 2058

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2058&root=pulseaudio&view=rev
Log:
use a free list for allocation pa_operation objects

Modified:
    trunk/src/pulse/operation.c

Modified: trunk/src/pulse/operation.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulse/operation.c?rev=2058&root=pulseaudio&r1=2057&r2=2058&view=diff
==============================================================================
--- trunk/src/pulse/operation.c (original)
+++ trunk/src/pulse/operation.c Wed Nov 14 17:11:09 2007
@@ -27,15 +27,20 @@
 
 #include <pulse/xmalloc.h>
 #include <pulsecore/macro.h>
+#include <pulsecore/flist.h>
 
 #include "internal.h"
 #include "operation.h"
+
+PA_STATIC_FLIST_DECLARE(operations, 0, pa_xfree);
 
 pa_operation *pa_operation_new(pa_context *c, pa_stream *s, pa_operation_cb_t cb, void *userdata) {
     pa_operation *o;
     pa_assert(c);
 
-    o = pa_xnew(pa_operation, 1);
+    if (!(o = pa_flist_pop(PA_STATIC_FLIST_GET(operations))))
+        o = pa_xnew(pa_operation, 1);
+
     PA_REFCNT_INIT(o);
     o->context = c;
     o->stream = s;
@@ -66,7 +71,9 @@
     if (PA_REFCNT_DEC(o) <= 0) {
         pa_assert(!o->context);
         pa_assert(!o->stream);
-        pa_xfree(o);
+
+        if (pa_flist_push(PA_STATIC_FLIST_GET(operations), o) < 0)
+            pa_xfree(o);
     }
 }
 




More information about the pulseaudio-commits mailing list