27 if (current_chunk == NULL)
31 tmp->
p_prev = current_chunk;
42 printf(
"Failled to allocate chunk \n");
46 tmp->
p_payload = malloc(size_of_trunk * size_of_payload);
49 printf(
"Failled to alloc chunk \n");
67 fprintf(stderr,
"Can't write to uninitialized chained_list in %s:%d\n", __FILE__, __LINE__);
71 if ( (*list)->size_of_trunk <= (*list)->current_offset ) {
81 void *push_addr = (
char *) (*list)->
p_payload + ((*list)->current_offset * (*list)->size_of_payload);
83 memcpy( push_addr, (
char *) p_payload, (*list)->size_of_payload);
85 (*list)->current_offset++;
94 fprintf(stderr,
"Can't merge chained lists of different types in %s:%d\n", __FILE__, __LINE__);
104 void *current_elem = NULL;
107 if ((condition) (current_elem))
135 void (*action) (
void *,
void *),
void *arg)
196 if( (test_func) (elem, value) ) {
200 if( *((uint64_t *)elem) == *((uint64_t *)value) ) {
struct chained_list * chained_list_alloc_next_chunk(struct chained_list *current_chunk)
Alocate a new chunk pointing to current_chunk (Recopy MODE )
int chained_list_count(struct chained_list *list)
Count elements in the chained list.
void * chained_list_push(struct chained_list **list, void *p_payload)
Push an element in the chained list.
Basic buffered chained list.
void chained_list_release(struct chained_list **list)
Release a buffered chained list.
size_t size_of_payload
Size of the payload.
void chained_list_walkthrough_arg(struct chained_list *list, void(*action)(void *, void *), void *arg)
Call a function uppon each element of the chained list.
struct chained_list * p_prev
previous trunk
void * chained_list_get_elem(struct chained_list *list, int(*test_func)(void *, void *), void *value)
Get a pointer to the first element which matches a value.
void chained_list_walkthrough(struct chained_list *list, void(*action)(void *))
Call a function uppon each element of the chained list.
void * p_payload
payload array of trunk
void cond_chained_list_merge(struct chained_list **dest, struct chained_list *source, int(*condition)(void *))
Push all element of source satisfying condition in dest.
uint32_t current_offset
Current offset in trunk.
struct chained_list * chained_list_init(uint32_t size_of_trunk, size_t size_of_payload)
Ininitalizes a buffered chained list.
struct chained_list * chained_list_alloc_chunk(uint32_t size_of_trunk, size_t size_of_payload)
Alocate a new chunk ( first chunk )
uint32_t size_of_trunk
Size of a trunk.