Crater Container Library 0.2.0
|
|
Function table for linked list. More...
#include <cll.h>
Data Fields | |
cr8r_base_ft | base |
Base function table values (data and size) | |
void *(* | alloc )(cr8r_base_ft *) |
allocate a new node. More... | |
void(* | del )(cr8r_base_ft *, void *p) |
deallocate a node, first cleaning up anything owned by its element if necessary. More... | |
void(* | copy )(cr8r_base_ft *, void *dest, const void *src) |
copy an element of the vector. More... | |
int(* | cmp )(const cr8r_base_ft *, const void *a, const void *b) |
compare two elements of the vector. More... | |
Function table for linked list.
Imagine this struct as the class of the linked list. This struct specifies the size of the elements in a list in bytes, as well as how to perform necessary operations (compare, copy, etc). Remember that function tables must be initialized manually. In particular, the cr8r_vec_default_* functions can be used as decent defaults, but must be explicitly set.
void*(* cr8r_cll_ft::alloc) (cr8r_base_ft *) |
void(* cr8r_cll_ft::del) (cr8r_base_ft *, void *p) |
deallocate a node, first cleaning up anything owned by its element if necessary.
to be safe, the allocation scheme should either zero out allocated memory before returning it OR not have elements own anything, since if neither of these things is done it's possible for this function to try to clean up a pointer in uninitialized memory, which is Very Bad.
void(* cr8r_cll_ft::copy) (cr8r_base_ft *, void *dest, const void *src) |
int(* cr8r_cll_ft::cmp) (const cr8r_base_ft *, const void *a, const void *b) |
compare two elements of the vector.
cr8r_default_cmp is a suitable default if needed. should return <0 if a < b, 0 if a == b, and >0 if a > b. should not return INT_MIN.