19 #ifndef __ARTIK_LIST_H__ 20 #define __ARTIK_LIST_H__ 57 typedef void *(*ARTIK_LIST_FUNCB) (
void *,
void *);
68 ARTIK_LIST_HANDLE handle;
69 unsigned int size_data;
78 #define ARTIK_LIST_INVALID_HANDLE NULL 93 ARTIK_LIST_HANDLE handle,
int size_of_node)
97 while ((elem != NULL) && (elem->next != NULL))
101 elem->next = (
artik_list *) malloc(size_of_node);
104 memset(elem->next, 0, size_of_node);
110 memset(elem, 0, size_of_node);
115 elem->handle = handle;
119 elem->size_data = size_of_node -
sizeof(*elem);
161 static inline unsigned int artik_list_size(
artik_list *list)
164 unsigned int res = 0;
187 if (!list || !*list || !node)
192 while (elem && (elem != node)) {
201 prev->next = elem->next;
205 (*elem->clear) (elem);
233 while (elem && (elem->handle != handle)) {
241 prev->next = elem->next;
245 (*elem->clear) (elem);
267 if (!list || !*list || (pos >= artik_list_size(*list)))
272 while (elem && pos > 0) {
281 prev->next = elem->next;
285 (*elem->clear) (elem);
307 void *param_of_check)
312 if (!list || !check_func)
317 while (elem && ((*check_func) (elem, param_of_check) == 0)) {
325 prev->next = elem->next;
329 (*elem->clear) (elem);
353 *list = (*list)->next;
355 (*elem->clear) (elem);
384 while (elem && (elem->handle != handle))
405 if (!list || (pos >= artik_list_size(list)))
408 while (elem && i++ < pos)
429 void *param_of_check)
433 if (!list || !check_func)
436 while (elem && ((*check_func) (elem, param_of_check) == 0))
454 while (elem && elem->next)
void * ARTIK_LIST_HANDLE
ARTIK_LIST_ID type.
void(* ARTIK_LIST_FUNCA)(void *)
ARTIK_LIST_FUNCA type.
#define S_OK
No error occurred while processing the function.
int artik_error
Error type.
#define E_BAD_ARGS
Wrong arguments passed to the function.
struct artik_list artik_list
Generic linked list structure.
void *(* ARTIK_LIST_FUNCB)(void *, void *)
ARTIK_LIST_FUNCB type.
#define ARTIK_LIST_INVALID_HANDLE
ARTIK_LIST_INVALID_HANDLE.
Generic linked list structure.