25#include "dbus-internals.h"
27#include "dbus-mempool.h"
28#include "dbus-threads-internal.h"
29#include <dbus/dbus-test-tap.h>
56alloc_link (
void *data)
63 if (list_pool ==
NULL)
67 if (list_pool ==
NULL)
100 "before we allocated a linked-list link");
124 link->
next = before_this_link;
125 link->
prev = before_this_link->
prev;
126 before_this_link->
prev = link;
129 if (before_this_link == *list)
147 link->
prev = after_this_link;
149 after_this_link->
next = link;
154#ifdef DBUS_ENABLE_STATS
156_dbus_list_get_stats (dbus_uint32_t *in_use_p,
157 dbus_uint32_t *in_free_list_p,
158 dbus_uint32_t *allocated_p)
168 _dbus_mem_pool_get_stats (list_pool, in_use_p, in_free_list_p, allocated_p);
245 return alloc_link (data);
278 *list = (*list)->
next;
298 link = alloc_link (data);
302 link_before (list, *list, link);
322 *list = (*list)->
next;
337 link_before (list, *list, link);
355 if (after_this_link ==
NULL)
359 link = alloc_link (data);
363 link_after (list, after_this_link, link);
381 if (before_this_link ==
NULL)
384 link_before (list, before_this_link, link);
399 if (after_this_link ==
NULL)
402 link_after (list, after_this_link, link);
424 if (link->
data == data)
482 if (link->
data == data)
503 if (link->
next == link)
578 function (link->
data);
613 return (*list)->prev;
629 return (*list)->prev->data;
645 return (*list)->data;
798 (* function) (link->
data, data);
813 return (*list !=
NULL &&
814 (*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.
void(* DBusForeachFunction)(void *element, void *data)
Used to iterate over each item in a collection, such as a DBusList.
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.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
void * data
Data stored at this element.
DBusList * next
Next list node.
DBusList * prev
Previous list node.
Internals fields of DBusMemPool.