CBuild wiki
Linked list. For merge with CBuild
License: GPL-3.0-or-later
This linked list is based on shadow data technique and never returns pointers to real linked list structures. It implements full doubly-linked list and this is why it does not need head node (but can assign first element as a head, or any other element, this implementation will happily consume pointer to any element and find start/end of linked list).
In reality, layout in memory will look something like this:
|void* prev|void* next|user-provided data| All functions
operate on pointer to this user-provided data block. All
internal information is hidden from user. On the other hand library
knows how to access this hidden data and implement linked list on top of
it. This allows for a lot cleaner API, were user directly have data it
wants.
Allocate new element in linked list. New memory would be zero-initialized.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list.
cbuild_allocator_t*
a Allocator.T* elem Any element of linked list.size_t size Length of a data section of element in
bytes.T* Pointer to new
element.
Allocate new element in linked list. New memory would be zero-initialized.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list.
T* elem Any element of linked list.size_t size Length of a data section of element in
bytes.T* Pointer to new
element.
Allocate new element in linked list. New memory would be zero-initialized.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list.
cbuild_arena_t*
arena Arena.T* elem Any element of linked list.size_t size Length of a data section of element in
bytes.T* Pointer to new
element.
Append element to linked list. This is semi-internal function.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
cbuild_allocator_t*
a Allocator.T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
It will be copied via memcpy.size_t size Length of a data in bytes.T* Pointer to new
element.
Append element to linked list. This is semi-internal function.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
It will be copied via memcpy.size_t size Length of a data in bytes.T* Pointer to new
element.
Append element to linked list. This is semi-internal function.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
cbuild_arena_t*
arena Arena.T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
It will be copied via memcpy.size_t size Length of a data in bytes.T* Pointer to new
element.
Append element to linked list.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
cbuild_allocator_t*
a Allocator.T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
Must be value and not pointer.T* Pointer to new
element.
Append element to linked list.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
Must be value and not pointer.T* Pointer to new
element.
Append element to linked list.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
cbuild_arena_t*
arena Arena.T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
Must be value and not pointer.T* Pointer to new
element.
Append element to linked list.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
cbuild_allocator_t*
a Allocator.T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
Must be typed (not void) pointer.T* Pointer to new
element.
Append element to linked list.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
Must be typed (not void) pointer.T* Pointer to new
element.
Append element to linked list.
This function will first iterate forward until it find end and then append new element.
If elemT* is
null then it will allocate new linked list. If elemT*
points to null then it will allocate new linked list. Element will be
also returned in elemT*
then.
cbuild_arena_t*
arena Arena.T* elem Any element of linked list. Pointer to
pointer to data of this element.T data Data that need to be put into new node.
Must be typed (not void) pointer.T* Pointer to new
element.
Get size of linked list in elements.
This will first iterate backward until it find start and then iterate forward until end is found and count number of elements.
T* elem Any element of linked list.Remove element from linked list.
cbuild_allocator_t*
a Allocator.T* elem Element of linked list that should be
removed.Free full linked list.
cbuild_allocator_t*
a Allocator.T* elem Any element of linked list.Get next element from linked list or NULL.
Get previous element from linked list or NULL.
Get head element from linked list.
Get tail element from linked list.