36 #ifndef UTILS_SRC_LLIST_H_ 37 #define UTILS_SRC_LLIST_H_ 39 #include <sys/types.h> 121 #define LLIST_DUPLICATE(ref_llist_dst, llist_src, node_dup_fxn, \ 122 node_dup_fxn_t, ret_code) \ 125 llist_t **_ref_llist_dst= ref_llist_dst;\ 126 const llist_t *_llist_src= llist_src;\ 127 node_dup_fxn_t*(*_node_dup_fxn)(const node_dup_fxn_t*)= node_dup_fxn;\ 129 ret_code= STAT_ERROR;\ 131 CHECK_DO(_ref_llist_dst!= NULL, break);\ 132 CHECK_DO(_node_dup_fxn!= NULL, break);\ 133 if(_llist_src== NULL) {\ 134 ret_code= STAT_SUCCESS;\ 139 void *node, *node_copy;\ 141 node= llist_get_nth(_llist_src, i);\ 143 ret_code= STAT_SUCCESS;\ 147 node_copy= _node_dup_fxn((const node_dup_fxn_t*)node);\ 148 CHECK_DO(node_copy!= NULL, break);\ 151 llist_insert_nth(_ref_llist_dst, i, node_copy)== STAT_SUCCESS,\ 165 #define LLIST_RELEASE(ref_llist_head, node_release_fxn, node_type) \ 166 while((*ref_llist_head)!= NULL) {\ 167 void (*_node_release_fxn)(node_type**)= node_release_fxn;\ 168 node_type *node= (node_type*)llist_pop(ref_llist_head);\ 169 if(node!= NULL) _node_release_fxn(&node);\ 170 ASSERT(node== NULL);\ int llist_push(llist_t **ref_llist_head, void *data)
int llist_len(const llist_t *llist_head)
void * llist_pop(llist_t **ref_llist_head)
void * llist_get_nth(const llist_t *llist_head, int index)
int llist_insert_nth(llist_t **ref_llist_head, int index, void *data)