diff options
author | Anders Carlsson <andersca@codefactory.se> | 2003-01-25 00:11:41 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@codefactory.se> | 2003-01-25 00:11:41 +0000 |
commit | a284b8071436e02064074e08d56dfcc6702c5250 (patch) | |
tree | f8d1e4782a6a5187164240be035f03374d114ca4 | |
parent | a16e83f45d33ae5f3bd5966416c57c8ad4448ae8 (diff) |
2003-01-25 Anders Carlsson <andersca@codefactory.se>
* dbus/dbus-list.c: (alloc_link), (free_link):
Use a memory pool for the links.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | dbus/dbus-list.c | 12 |
2 files changed, 13 insertions, 4 deletions
@@ -1,5 +1,10 @@ 2003-01-25 Anders Carlsson <andersca@codefactory.se> + * dbus/dbus-list.c: (alloc_link), (free_link): + Use a memory pool for the links. + +2003-01-25 Anders Carlsson <andersca@codefactory.se> + * bus/connection.c: (bus_connection_foreach): * bus/connection.h: Add new bus_connection_foreach function. diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index c36246cb..42fc79bf 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -23,6 +23,7 @@ #include "dbus-internals.h" #include "dbus-list.h" +#include "dbus-mempool.h" /** * @defgroup DBusList Linked list @@ -32,6 +33,8 @@ * Types and functions related to DBusList. */ +static DBusMemPool *list_pool; + /** * @defgroup DBusListInternals Linked list implementation details * @ingroup DBusInternals @@ -39,8 +42,6 @@ * * The guts of DBusList. * - * @todo should use a memory pool for the list nodes, to avoid - * a memory allocation for every link. * @{ */ @@ -49,7 +50,10 @@ alloc_link (void *data) { DBusList *link; - link = dbus_new0 (DBusList, 1); + if (!list_pool) + list_pool = _dbus_mem_pool_new (sizeof (DBusList), TRUE); + + link = _dbus_mem_pool_alloc (list_pool); link->data = data; return link; @@ -58,7 +62,7 @@ alloc_link (void *data) static void free_link (DBusList *link) { - dbus_free (link); + _dbus_mem_pool_dealloc (list_pool, link); } static void |