D-Bus 1.14.10
|
DBusList data structure. More...
Data Structures | |
struct | DBusList |
A node in a linked list. More... | |
Macros | |
#define | _dbus_list_get_next_link(list, link) ((link)->next == *(list) ? NULL : (link)->next) |
Gets the next link in the list, or NULL if there are no more links. More... | |
#define | _dbus_list_get_prev_link(list, link) ((link) == *(list) ? NULL : (link)->prev) |
Gets the previous link in the list, or NULL if there are no more links. More... | |
Functions | |
DBusList * | _dbus_list_alloc_link (void *data) |
Allocates a linked list node. More... | |
void | _dbus_list_free_link (DBusList *link) |
Frees a linked list node allocated with _dbus_list_alloc_link. More... | |
dbus_bool_t | _dbus_list_append (DBusList **list, void *data) |
Appends a value to the list. More... | |
dbus_bool_t | _dbus_list_prepend (DBusList **list, void *data) |
Prepends a value to the list. More... | |
void | _dbus_list_append_link (DBusList **list, DBusList *link) |
Appends a link to the list. More... | |
void | _dbus_list_prepend_link (DBusList **list, DBusList *link) |
Prepends a link to the list. More... | |
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. More... | |
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. More... | |
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. More... | |
dbus_bool_t | _dbus_list_remove (DBusList **list, void *data) |
Removes a value from the list. More... | |
dbus_bool_t | _dbus_list_remove_last (DBusList **list, void *data) |
Removes a value from the list. More... | |
DBusList * | _dbus_list_find_last (DBusList **list, void *data) |
Finds a value in the list. More... | |
void | _dbus_list_unlink (DBusList **list, DBusList *link) |
Removes the given link from the list, but doesn't free it. More... | |
void | _dbus_list_remove_link (DBusList **list, DBusList *link) |
Removes a link from the list. More... | |
void | _dbus_list_clear (DBusList **list) |
Frees all links in the list and sets the list head to NULL. More... | |
void | _dbus_list_clear_full (DBusList **list, DBusFreeFunction function) |
Free every link and every element in the list. More... | |
DBusList * | _dbus_list_get_first_link (DBusList **list) |
Gets the first link in the list. More... | |
DBusList * | _dbus_list_get_last_link (DBusList **list) |
Gets the last link in the list. More... | |
void * | _dbus_list_get_last (DBusList **list) |
Gets the last data in the list. More... | |
void * | _dbus_list_get_first (DBusList **list) |
Gets the first data in the list. More... | |
DBusList * | _dbus_list_pop_first_link (DBusList **list) |
Removes the first link in the list and returns it. More... | |
void * | _dbus_list_pop_first (DBusList **list) |
Removes the first value in the list and returns it. More... | |
void * | _dbus_list_pop_last (DBusList **list) |
Removes the last value in the list and returns it. More... | |
dbus_bool_t | _dbus_list_copy (DBusList **list, DBusList **dest) |
Copies a list. More... | |
int | _dbus_list_get_length (DBusList **list) |
Gets the length of a list. More... | |
void | _dbus_list_foreach (DBusList **list, DBusForeachFunction function, void *data) |
Calls the given function for each element in the list. More... | |
dbus_bool_t | _dbus_list_length_is_one (DBusList **list) |
Check whether length is exactly one. More... | |
DBusList data structure.
Types and functions related to DBusList.
#define _dbus_list_get_next_link | ( | list, | |
link | |||
) | ((link)->next == *(list) ? NULL : (link)->next) |
Gets the next link in the list, or NULL if there are no more links.
Used for iteration.
list | address of the list head. |
link | current link. |
Definition at line 119 of file dbus-list.h.
#define _dbus_list_get_prev_link | ( | list, | |
link | |||
) | ((link) == *(list) ? NULL : (link)->prev) |
Gets the previous link in the list, or NULL if there are no more links.
Used for iteration.
list | address of the list head. |
link | current link. |
Definition at line 120 of file dbus-list.h.
DBusList * _dbus_list_alloc_link | ( | void * | data | ) |
Allocates a linked list node.
Useful for preallocating nodes and using _dbus_list_append_link() to avoid allocations.
data | the value to store in the link. |
Definition at line 243 of file dbus-list.c.
Referenced by _dbus_message_add_counter(), and _dbus_pending_call_set_timeout_error_unlocked().
dbus_bool_t _dbus_list_append | ( | DBusList ** | list, |
void * | data | ||
) |
Appends a value to the list.
May return FALSE if insufficient memory exists to add a list link. This is a constant-time operation.
list | address of the list head. |
data | the value to append. |
Definition at line 271 of file dbus-list.c.
References _dbus_list_prepend(), FALSE, next, and TRUE.
Referenced by _dbus_list_copy(), _dbus_set_up_transient_session_servicedirs(), _dbus_split_paths_and_append(), _dbus_timeout_list_add_timeout(), _dbus_validate_signature_with_reason(), _dbus_watch_list_add_watch(), and dbus_connection_add_filter().
Appends a link to the list.
Cannot fail due to out of memory. This is a constant-time operation.
list | address of the list head. |
link | the link to append. |
Definition at line 316 of file dbus-list.c.
References _dbus_list_prepend_link(), and next.
Referenced by _dbus_connection_queue_received_message_link(), _dbus_connection_queue_synthesized_message_link(), _dbus_list_insert_before_link(), and _dbus_message_add_counter_link().
void _dbus_list_clear | ( | DBusList ** | list | ) |
Frees all links in the list and sets the list head to NULL.
Does not free the data in each link, for obvious reasons. This is a linear-time operation.
list | address of the list head. |
Definition at line 543 of file dbus-list.c.
References _dbus_list_get_next_link, and NULL.
Referenced by _dbus_list_copy(), and _dbus_pending_call_set_reply_unlocked().
void _dbus_list_clear_full | ( | DBusList ** | list, |
DBusFreeFunction | function | ||
) |
Free every link and every element in the list.
list | address of the head of the list. |
function | free-function to call for each element. |
Definition at line 568 of file dbus-list.c.
References _dbus_list_get_next_link, data, and NULL.
Referenced by _dbus_message_loader_unref(), _dbus_split_paths_and_append(), _dbus_timeout_list_free(), and _dbus_watch_list_free().
dbus_bool_t _dbus_list_copy | ( | DBusList ** | list, |
DBusList ** | dest | ||
) |
Copies a list.
This is a linear-time operation. If there isn't enough memory to copy the entire list, the destination list will be set to NULL.
list | address of the head of the list to copy. |
dest | address where the copied list should be placed. |
Definition at line 725 of file dbus-list.c.
References _dbus_assert, _dbus_list_append(), _dbus_list_clear(), _dbus_list_get_next_link, data, FALSE, NULL, and TRUE.
Finds a value in the list.
Returns the last link with value equal to the given data pointer. This is a linear-time operation. Returns NULL if no value found that matches.
list | address of the list head. |
data | the value to find. |
Definition at line 473 of file dbus-list.c.
References _dbus_list_get_last_link(), _dbus_list_get_prev_link, data, and NULL.
Referenced by _dbus_list_remove_last(), and _dbus_message_remove_counter().
void _dbus_list_foreach | ( | DBusList ** | list, |
DBusForeachFunction | function, | ||
void * | data | ||
) |
Calls the given function for each element in the list.
The function is passed the list element as its first argument, and the given data as its second argument.
list | address of the head of the list. |
function | function to call for each element. |
data | extra data for the function. |
Definition at line 787 of file dbus-list.c.
References _dbus_list_get_next_link, data, and NULL.
Referenced by _dbus_timeout_list_set_functions().
void _dbus_list_free_link | ( | DBusList * | link | ) |
Frees a linked list node allocated with _dbus_list_alloc_link.
Does not free the data in the node.
link | the list node |
Definition at line 255 of file dbus-list.c.
Referenced by _dbus_connection_unlock(), and dbus_connection_free_preallocated_send().
void * _dbus_list_get_first | ( | DBusList ** | list | ) |
Gets the first data in the list.
This is a constant-time operation.
list | address of the list head. |
Definition at line 640 of file dbus-list.c.
References NULL.
Gets the first link in the list.
This is a constant-time operation.
list | address of the list head. |
Definition at line 595 of file dbus-list.c.
Referenced by _dbus_list_pop_first(), _dbus_list_pop_first_link(), _dbus_timeout_list_set_functions(), _dbus_watch_list_set_functions(), _dbus_watch_list_toggle_all_watches(), and dbus_address_entry_get_value().
void * _dbus_list_get_last | ( | DBusList ** | list | ) |
Gets the last data in the list.
This is a constant-time operation.
list | address of the list head. |
Definition at line 624 of file dbus-list.c.
References NULL.
Referenced by _dbus_connection_get_message_to_send().
Gets the last link in the list.
This is a constant-time operation.
list | address of the list head. |
Definition at line 608 of file dbus-list.c.
References NULL.
Referenced by _dbus_connection_message_sent_unlocked(), _dbus_list_find_last(), _dbus_list_pop_last(), and dbus_connection_remove_filter().
int _dbus_list_get_length | ( | DBusList ** | list | ) |
Gets the length of a list.
This is a linear-time operation.
list | address of the head of the list |
Definition at line 758 of file dbus-list.c.
References _dbus_list_get_next_link, and NULL.
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.
list | the list to modify |
after_this_link | existing link to insert after, or NULL to prepend |
data | the value to insert |
Definition at line 349 of file dbus-list.c.
References _dbus_list_prepend(), and NULL.
Inserts a link into the list after the given existing link.
list | the list to modify |
after_this_link | existing link to insert after, or NULL to prepend |
link | the link to insert |
Definition at line 395 of file dbus-list.c.
References _dbus_list_prepend_link(), and NULL.
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.
list | the list to modify |
before_this_link | existing link to insert before, or NULL to append |
link | the link to insert |
Definition at line 377 of file dbus-list.c.
References _dbus_list_append_link(), and NULL.
dbus_bool_t _dbus_list_length_is_one | ( | DBusList ** | list | ) |
Check whether length is exactly one.
list | the list |
Definition at line 811 of file dbus-list.c.
References NULL.
void * _dbus_list_pop_first | ( | DBusList ** | list | ) |
Removes the first value in the list and returns it.
This is a constant-time operation.
list | address of the list head. |
Definition at line 677 of file dbus-list.c.
References _dbus_list_get_first_link(), _dbus_list_remove_link(), data, and NULL.
Referenced by _dbus_message_loader_pop_message(), and dbus_connection_steal_borrowed_message().
Removes the first link in the list and returns it.
This is a constant-time operation.
list | address of the list head. |
Definition at line 656 of file dbus-list.c.
References _dbus_list_get_first_link(), _dbus_list_unlink(), and NULL.
Referenced by _dbus_connection_unlock(), and _dbus_message_loader_pop_message_link().
void * _dbus_list_pop_last | ( | DBusList ** | list | ) |
Removes the last value in the list and returns it.
This is a constant-time operation.
list | address of the list head. |
Definition at line 700 of file dbus-list.c.
References _dbus_list_get_last_link(), _dbus_list_remove_link(), data, and NULL.
dbus_bool_t _dbus_list_prepend | ( | DBusList ** | list, |
void * | data | ||
) |
Prepends a value to the list.
May return FALSE if insufficient memory exists to add a list link. This is a constant-time operation.
list | address of the list head. |
data | the value to prepend. |
Definition at line 293 of file dbus-list.c.
Referenced by _dbus_list_append(), and _dbus_list_insert_after().
Prepends a link to the list.
Cannot fail due to out of memory. This is a constant-time operation.
list | address of the list head. |
link | the link to prepend. |
Definition at line 334 of file dbus-list.c.
Referenced by _dbus_connection_message_sent_unlocked(), _dbus_list_append_link(), _dbus_list_insert_after_link(), and _dbus_message_loader_putback_message_link().
dbus_bool_t _dbus_list_remove | ( | DBusList ** | list, |
void * | data | ||
) |
Removes a value from the list.
Only removes the first value equal to the given data pointer, even if multiple values exist which match. This is a linear-time operation.
list | address of the list head. |
data | the value to remove. |
Definition at line 416 of file dbus-list.c.
References _dbus_list_get_next_link, _dbus_list_remove_link(), data, FALSE, NULL, and TRUE.
Referenced by _dbus_timeout_list_remove_timeout(), and _dbus_watch_list_remove_watch().
dbus_bool_t _dbus_list_remove_last | ( | DBusList ** | list, |
void * | data | ||
) |
Removes a value from the list.
Only removes the last value equal to the given data pointer, even if multiple values exist which match. This is a linear-time operation.
list | address of the list head. |
data | the value to remove. |
Definition at line 447 of file dbus-list.c.
References _dbus_list_find_last(), _dbus_list_remove_link(), FALSE, and TRUE.
Referenced by _dbus_timeout_list_add_timeout().
Removes a link from the list.
This is a constant-time operation.
list | address of the list head. |
link | the list link to remove. |
Definition at line 528 of file dbus-list.c.
References _dbus_list_unlink().
Referenced by _dbus_list_pop_first(), _dbus_list_pop_last(), _dbus_list_remove(), _dbus_list_remove_last(), _dbus_message_remove_counter(), and dbus_connection_remove_filter().
Removes the given link from the list, but doesn't free it.
_dbus_list_remove_link() both removes the link and also frees it.
list | the list |
link | the link in the list |
Definition at line 500 of file dbus-list.c.
References next, NULL, and prev.
Referenced by _dbus_connection_message_sent_unlocked(), _dbus_list_pop_first_link(), and _dbus_list_remove_link().