00001 #ifndef _LIST_H
00002 #define _LIST_H
00003
00004 #include "jsoc.h"
00005
00006 struct ListNode_struct
00007 {
00008 void *data;
00009 struct ListNode_struct *next;
00010 };
00011 typedef struct ListNode_struct ListNode_t;
00012
00013 typedef void(* ListFreeFn_t)(void *);
00014
00015 struct LinkedList_struct
00016 {
00017 unsigned int dsize;
00018 ListFreeFn_t freefn;
00019 ListNode_t *first;
00020 ListNode_t *next;
00021 int nitems;
00022 };
00023 typedef struct LinkedList_struct LinkedList_t;
00024
00025 LinkedList_t *list_llcreate(unsigned int datasize, ListFreeFn_t freefn);
00026 ListNode_t *list_llinserthead(LinkedList_t *llist, void *data);
00027 ListNode_t *list_llinserttail(LinkedList_t *llist, void *data);
00028 void list_llremove(LinkedList_t *llist, ListNode_t *item);
00029 void list_llreset(LinkedList_t *llist);
00030 ListNode_t *list_llnext(LinkedList_t *llist);
00031 ListNode_t *list_llfind(LinkedList_t *llist, void *data);
00032 ListNode_t *list_llgettail(LinkedList_t *llist);
00033
00034 static inline ListNode_t *list_llgethead(LinkedList_t *llist)
00035 {
00036 if (llist)
00037 {
00038 return llist->first;
00039 }
00040
00041 return NULL;
00042 }
00043
00044 static inline int list_llgetnitems(LinkedList_t *llist)
00045 {
00046 return llist->nitems;
00047 }
00048
00049 void list_llfree(LinkedList_t **llist);
00050 void list_llfreenode(ListNode_t **node);
00051
00052 #endif