|
rlib
Convenience library for useful things
|
Doubly- and singly-linked list templates plus the four callback-flavoured specialisations that the rest of rlib uses to manage deferred work. More...
Files | |
| file | rlist.h |
| Linked-list types: doubly / singly linked plus the callback-flavoured specialisations. | |
Data Structures | |
| struct | RFreePtrCtx |
(pointer, destroy-notifier) pair stored in RFreeList. More... | |
Free list — defer cleanup of heterogeneous resources | |
| static RFreeList * | r_free_list_alloc (rpointer ptr, RDestroyNotify notify) |
| static RFreeList * | r_free_list_prepend (RFreeList *lst, rpointer ptr, RDestroyNotify notify) |
Callback list (RCBList — doubly-linked) | |
Doubly-linked list of RFuncCallbackCtx tuples. Use for "fire these callbacks later in order" patterns where the caller also needs to walk in reverse. | |
| RCBList * | r_cblist_alloc_full (RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) |
| Allocate a standalone callback node with full ownership wiring. | |
| RCBList * | r_cblist_prepend_full (RCBList *head, RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) R_ATTR_WARN_UNUSED_RESULT |
| Prepend a new callback to the head with full ownership wiring. | |
| RCBList * | r_cblist_append_full (RCBList *entry, RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) R_ATTR_WARN_UNUSED_RESULT |
| Append a new callback to the tail with full ownership wiring. | |
| rboolean | r_cblist_contains (RCBList *head, RFunc cb, rpointer data) |
TRUE iff head contains a matching (cb, data) pair. | |
| rsize | r_cblist_call (RCBList *head) |
| Invoke every callback in the list in order; returns the number called. | |
| #define | r_cblist_alloc(cb, data, user) r_cblist_alloc_full (cb, data, NULL, user, NULL) |
| Convenience: allocate without destroy notifiers. | |
| #define | r_cblist_prepend(head, cb, data, user) r_cblist_prepend_full (head, cb, data, NULL, user, NULL) |
| Convenience: prepend without destroy notifiers. | |
| #define | r_cblist_append(head, cb, data, user) r_cblist_append_full (head, cb, data, NULL, user, NULL) |
| Convenience: append without destroy notifiers. | |
Return-value callback list (RCBRList — doubly-linked) | |
Same shape as | |
| RCBRList * | r_cbrlist_alloc_full (RFuncReturn cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) |
| Allocate a standalone return-callback node with full ownership wiring. | |
| RCBRList * | r_cbrlist_prepend_full (RCBRList *head, RFuncReturn cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) R_ATTR_WARN_UNUSED_RESULT |
| Prepend a return-callback to the head. | |
| RCBRList * | r_cbrlist_append_full (RCBRList *entry, RFuncReturn cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) R_ATTR_WARN_UNUSED_RESULT |
| Append a return-callback to the tail. | |
| rboolean | r_cbrlist_contains (RCBRList *head, RFuncReturn cb, rpointer data) |
TRUE iff head contains a matching (cb, data) pair. | |
| RCBRList * | r_cbrlist_call (RCBRList *head) R_ATTR_WARN_UNUSED_RESULT |
Iterate the list, removing entries whose callback returned FALSE. | |
| #define | r_cbrlist_alloc(cb, data, user) r_cbrlist_alloc_full (cb, data, NULL, user, NULL) |
| Convenience: allocate without destroy notifiers. | |
| #define | r_cbrlist_prepend(head, cb, data, user) r_cbrlist_prepend_full (head, cb, data, NULL, user, NULL) |
| Convenience: prepend without destroy notifiers. | |
| #define | r_cbrlist_append(head, cb, data, user) r_cbrlist_append_full (head, cb, data, NULL, user, NULL) |
| Convenience: append without destroy notifiers. | |
Callback list (RCBSList — singly-linked) | |
Same surface as | |
| RCBSList * | r_cbslist_alloc_full (RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) |
| Allocate a standalone callback node (singly-linked). | |
| RCBSList * | r_cbslist_prepend_full (RCBSList *head, RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) R_ATTR_WARN_UNUSED_RESULT |
| Prepend a new callback. | |
| RCBSList * | r_cbslist_append_full (RCBSList *entry, RFunc cb, rpointer data, RDestroyNotify datanotify, rpointer user, RDestroyNotify usernotify) R_ATTR_WARN_UNUSED_RESULT |
| Append a new callback. | |
| rboolean | r_cbslist_contains (RCBSList *head, RFunc cb, rpointer data) |
TRUE iff head contains a matching (cb, data) pair. | |
| rsize | r_cbslist_call (RCBSList *head) |
| Invoke every callback in the list; returns the number called. | |
| #define | r_cbslist_alloc(cb, data, user) r_cbslist_alloc_full (cb, data, NULL, user, NULL) |
| Convenience: allocate without destroy notifiers. | |
| #define | r_cbslist_prepend(head, cb, data, user) r_cbslist_prepend_full (head, cb, data, NULL, user, NULL) |
| Convenience: prepend without destroy notifiers. | |
| #define | r_cbslist_append(head, cb, data, user) r_cbslist_append_full (head, cb, data, NULL, user, NULL) |
| Convenience: append without destroy notifiers. | |
Doubly- and singly-linked list templates plus the four callback-flavoured specialisations that the rest of rlib uses to manage deferred work.
Five list types are declared in this header, all generated from R__LIST_DECL / R__SLIST_DECL templates in rlist-internal.h so the surface is uniform across types:
RList — doubly-linked list of rpointer values.RSList — singly-linked list of rpointer values.RFreeList — singly-linked free list pairing a pointer with its destroy notifier; used to defer cleanup of heterogeneous resources.RCBList / RCBSList — doubly- / singly-linked callback lists keyed on RFuncCallbackCtx tuples.RCBRList — doubly-linked list of RFuncReturnCallbackCtx tuples (return-value drives whether the iterator continues).Each type carries the standard set of _alloc / _alloc_full / _prepend / _append / _contains / _destroy accessors emitted by the template. The macros in this header (r_list_prepend = r_list_prepend_copy etc.) make value-by-copy the default insertion path.
| RCBRList * r_cbrlist_call | ( | RCBRList * | head | ) |
Iterate the list, removing entries whose callback returned FALSE.