[pulseaudio-commits] r2057 - /trunk/src/pulsecore/pdispatch.c

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


Author: lennart
Date: Wed Nov 14 17:10:36 2007
New Revision: 2057

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2057&root=pulseaudio&view=rev
Log:
use a free list for allocating reply_info structs

Modified:
    trunk/src/pulsecore/pdispatch.c

Modified: trunk/src/pulsecore/pdispatch.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/pdispatch.c?rev=2057&root=pulseaudio&r1=2056&r2=2057&view=diff
==============================================================================
--- trunk/src/pulsecore/pdispatch.c (original)
+++ trunk/src/pulsecore/pdispatch.c Wed Nov 14 17:10:36 2007
@@ -38,6 +38,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/macro.h>
 #include <pulsecore/refcnt.h>
+#include <pulsecore/flist.h>
 
 #include "pdispatch.h"
 
@@ -98,6 +99,8 @@
 
 #endif
 
+PA_STATIC_FLIST_DECLARE(reply_infos, 0, pa_xfree);
+
 struct reply_info {
     pa_pdispatch *pdispatch;
     PA_LLIST_FIELDS(struct reply_info);
@@ -129,7 +132,8 @@
 
     PA_LLIST_REMOVE(struct reply_info, r->pdispatch->replies, r);
 
-    pa_xfree(r);
+    if (pa_flist_push(PA_STATIC_FLIST_GET(reply_infos), r) < 0)
+        pa_xfree(r);
 }
 
 pa_pdispatch* pa_pdispatch_new(pa_mainloop_api *mainloop, const pa_pdispatch_cb_t*table, unsigned entries) {
@@ -273,7 +277,9 @@
     pa_assert(PA_REFCNT_VALUE(pd) >= 1);
     pa_assert(cb);
 
-    r = pa_xnew(struct reply_info, 1);
+    if (!(r = pa_flist_pop(PA_STATIC_FLIST_GET(reply_infos))))
+        r = pa_xnew(struct reply_info, 1);
+
     r->pdispatch = pd;
     r->callback = cb;
     r->userdata = userdata;




More information about the pulseaudio-commits mailing list