00001 #ifndef NPS_LIST_H 00002 #define NPS_LIST_H 00003 00004 #include <stdint.h> 00005 00006 /* Store either raw data (up to 8 bytes) or a pointer */ 00007 00008 typedef struct _nps_list_node_t { 00009 union { char buf[8] ; void *ptr; } data; 00010 struct _nps_list_node_t *next; 00011 } nps_list_node_t; /* no typedef here due to recursion (my argument passing convention) */ 00012 00013 00014 typedef struct { 00015 uint64_t size; 00016 nps_list_node_t *first; 00017 nps_list_node_t *last; 00018 } nps_list_t; 00019 00020 extern nps_list_t *nps_list_new(); 00021 extern void nps_list_prepend(nps_list_t *list, nps_list_node_t *item); 00022 extern void nps_list_append(nps_list_t *list, nps_list_node_t *item); 00023 extern struct nps_list_node_t *nps_list_nth(nps_list_t *list, uint64_t n); 00024 00025 #endif