27#include "dbus-internals.h"
29#include "dbus-mempool.h"
30#include "dbus-threads-internal.h"
31#include <dbus/dbus-test-tap.h>
58alloc_link (
void *data)
65 if (list_pool ==
NULL)
69 if (list_pool ==
NULL)
102 "before we allocated a linked-list link");
126 link->
next = before_this_link;
127 link->
prev = before_this_link->
prev;
128 before_this_link->
prev = link;
131 if (before_this_link == *list)
149 link->
prev = after_this_link;
151 after_this_link->
next = link;
156#ifdef DBUS_ENABLE_STATS
158_dbus_list_get_stats (dbus_uint32_t *in_use_p,
159 dbus_uint32_t *in_free_list_p,
160 dbus_uint32_t *allocated_p)
170 _dbus_mem_pool_get_stats (list_pool, in_use_p, in_free_list_p, allocated_p);
247 return alloc_link (data);
280 *list = (*list)->
next;
300 link = alloc_link (data);
304 link_before (list, *list, link);
324 *list = (*list)->
next;
339 link_before (list, *list, link);
357 if (after_this_link ==
NULL)
361 link = alloc_link (data);
365 link_after (list, after_this_link, link);
383 if (before_this_link ==
NULL)
386 link_before (list, before_this_link, link);
401 if (after_this_link ==
NULL)
404 link_after (list, after_this_link, link);
426 if (link->
data == data)
484 if (link->
data == data)
505 if (link->
next == link)
580 function (link->
data);
615 return (*list)->
prev;
631 return (*list)->prev->data;
647 return (*list)->data;
790 DBusForeachFunction function,
800 (* function) (link->
data, data);
815 return (*list !=
NULL &&
816 (*list)->
next == *list);
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
#define _DBUS_UNLOCK(name)
Unlocks a global lock.
#define _DBUS_LOCK(name)
Locks a global lock, initializing it first if necessary.
DBusList * _dbus_list_get_first_link(DBusList **list)
Gets the first link in the list.
void _dbus_list_insert_before_link(DBusList **list, DBusList *before_this_link, DBusList *link)
Inserts a link into the list before the given existing link.
dbus_bool_t _dbus_list_copy(DBusList **list, DBusList **dest)
Copies a list.
DBusList * _dbus_list_pop_first_link(DBusList **list)
Removes the first link in the list and returns it.
dbus_bool_t _dbus_list_length_is_one(DBusList **list)
Check whether length is exactly one.
void * _dbus_list_get_last(DBusList **list)
Gets the last data in the list.
dbus_bool_t _dbus_list_remove(DBusList **list, void *data)
Removes a value from the list.
void _dbus_list_append_link(DBusList **list, DBusList *link)
Appends a link to the list.
void _dbus_list_insert_after_link(DBusList **list, DBusList *after_this_link, DBusList *link)
Inserts a link into the list after the given existing link.
void _dbus_list_clear_full(DBusList **list, DBusFreeFunction function)
Free every link and every element in the list.
dbus_bool_t _dbus_list_insert_after(DBusList **list, DBusList *after_this_link, void *data)
Inserts data into the list after the given existing link.
void _dbus_list_remove_link(DBusList **list, DBusList *link)
Removes a link from the list.
void * _dbus_list_get_first(DBusList **list)
Gets the first data in the list.
DBusList * _dbus_list_get_last_link(DBusList **list)
Gets the last link in the list.
void _dbus_list_unlink(DBusList **list, DBusList *link)
Removes the given link from the list, but doesn't free it.
DBusList * _dbus_list_find_last(DBusList **list, void *data)
Finds a value in the list.
void * _dbus_list_pop_last(DBusList **list)
Removes the last value in the list and returns it.
#define _dbus_list_get_prev_link(list, link)
Gets the previous link in the list, or NULL if there are no more links.
void _dbus_list_free_link(DBusList *link)
Frees a linked list node allocated with _dbus_list_alloc_link.
void * _dbus_list_pop_first(DBusList **list)
Removes the first value in the list and returns it.
void _dbus_list_foreach(DBusList **list, DBusForeachFunction function, void *data)
Calls the given function for each element in the list.
int _dbus_list_get_length(DBusList **list)
Gets the length of a list.
void _dbus_list_clear(DBusList **list)
Frees all links in the list and sets the list head to NULL.
void _dbus_list_prepend_link(DBusList **list, DBusList *link)
Prepends a link to the list.
dbus_bool_t _dbus_list_prepend(DBusList **list, void *data)
Prepends a value to the list.
DBusList * _dbus_list_alloc_link(void *data)
Allocates a linked list node.
dbus_bool_t _dbus_list_remove_last(DBusList **list, void *data)
Removes a value from the list.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
#define _dbus_list_get_next_link(list, link)
Gets the next link in the list, or NULL if there are no more links.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void * _dbus_mem_pool_alloc(DBusMemPool *pool)
Allocates an object from the memory pool.
dbus_bool_t _dbus_mem_pool_dealloc(DBusMemPool *pool, void *element)
Deallocates an object previously created with _dbus_mem_pool_alloc().
void _dbus_mem_pool_free(DBusMemPool *pool)
Frees a memory pool (and all elements allocated from it).
DBusMemPool * _dbus_mem_pool_new(int element_size, dbus_bool_t zero_elements)
Creates a new memory pool, or returns NULL on failure.
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
void * data
Data stored at this element.
DBusList * next
Next list node.
DBusList * prev
Previous list node.
Internals fields of DBusMemPool.