Changeset 11473 for trunk/oscam-llist.h
- Timestamp:
- 01/18/19 20:17:57 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-llist.h
r11306 r11473 1 2 1 /* singularly linked-list */ 3 2 … … 15 14 struct llist 16 15 { 17 // 16 //void *obj; 18 17 LL_NODE *initial; 19 18 LL_NODE *last; … … 21 20 CS_MUTEX_LOCK lock; 22 21 int32_t flag; 23 uint32_t version; 22 uint32_t version; // updated on every modification of the list - exception is on prepends and appends as this should not have impacts on iterations! 24 23 }; 25 24 … … 40 39 }; 41 40 42 LLIST *ll_create(const char *name); // create llist, return ptr to llist43 void ll_destroy(LLIST **pl); // same as ll_clear_abstract() but frees up LLIST mem as well44 void ll_destroy_data(LLIST **pl); // same as ll_clear_data() but frees up obj allocations as well41 LLIST *ll_create(const char *name); // create llist, return ptr to llist 42 void ll_destroy(LLIST **pl); // same as ll_clear_abstract() but frees up LLIST mem as well 43 void ll_destroy_data(LLIST **pl); // same as ll_clear_data() but frees up obj allocations as well 45 44 void ll_destroy_free_data(LLIST **pl); // same as ll_clear_data() but frees up obj allocations as well. More, really free node without use GBC 46 45 47 void ll_clear(LLIST *l); // frees up all llnodes nodes but not data held in obj ptrs48 void ll_clear_data(LLIST *l); // same as ll_clear_data() but frees up obj allocations as well46 void ll_clear(LLIST *l); // frees up all llnodes nodes but not data held in obj ptrs 47 void ll_clear_data(LLIST *l); // same as ll_clear_data() but frees up obj allocations as well 49 48 50 49 void **ll_sort(const LLIST *l, void *compare, int32_t *size); // sorts the list, compare = int func(const T *a, const T *b) 51 LL_NODE *ll_append(LLIST *l, void *obj); // append obj to llist52 LL_NODE *ll_prepend(LLIST *l, void *obj); // prepend obj to llist50 LL_NODE *ll_append(LLIST *l, void *obj); // append obj to llist 51 LL_NODE *ll_prepend(LLIST *l, void *obj); // prepend obj to llist 53 52 54 // clones a list, duplicates data53 // clones a list, duplicates data 55 54 LLIST *ll_clone(LLIST *l, uint32_t copysize); 56 55 57 // New type of lock, list is locked during iterate! create=lock, destroy=unlock56 // New type of lock, list is locked during iterate! create=lock, destroy=unlock 58 57 LL_LOCKITER *ll_li_create(LLIST *l, int32_t writelock); 59 58 void ll_li_destroy(LL_LOCKITER *li); 60 59 void *ll_li_next(LL_LOCKITER *li); 61 60 62 // Old Iterators:63 LL_ITER ll_iter_create(LLIST *l); // return ptr to iterator obj64 void *ll_iter_next(LL_ITER *it); // iterate to and return next llnode obj, returns NULL at end61 // Old Iterators: 62 LL_ITER ll_iter_create(LLIST *l); // return ptr to iterator obj 63 void *ll_iter_next(LL_ITER *it); // iterate to and return next llnode obj, returns NULL at end 65 64 void *ll_iter_next_remove(LL_ITER *it); // iterate to and return next llnode obj, returns NULL at end, removing it 66 65 void *ll_iter_peek(const LL_ITER *it, int32_t offset); // return obj at offset from iterator but do not iterate 67 void ll_iter_reset(LL_ITER *it); // reset itrerator to first llnode68 void ll_iter_insert(LL_ITER *it, void *obj); // insert obj at iterator node69 void *ll_iter_remove(LL_ITER *it); // remove llnode at iterator, returns ptr to the llnode obj removed70 void ll_iter_remove_data(LL_ITER *it); // remove llnode and free llnode obj71 void *ll_iter_move(LL_ITER *it, int32_t offset); // moves the iterator position72 int32_t ll_iter_move_first(LL_ITER *it); // moves an entry to top73 static inline int32_t ll_count(const LLIST *l) 66 void ll_iter_reset(LL_ITER *it); // reset itrerator to first llnode 67 void ll_iter_insert(LL_ITER *it, void *obj); // insert obj at iterator node 68 void *ll_iter_remove(LL_ITER *it); // remove llnode at iterator, returns ptr to the llnode obj removed 69 void ll_iter_remove_data(LL_ITER *it); // remove llnode and free llnode obj 70 void *ll_iter_move(LL_ITER *it, int32_t offset); // moves the iterator position 71 int32_t ll_iter_move_first(LL_ITER *it); // moves an entry to top 72 static inline int32_t ll_count(const LLIST *l) // return number of items in list 74 73 { 75 74 if(!l || l->flag) … … 78 77 return l->count; 79 78 } 80 void *ll_has_elements(const LLIST *l); 79 void *ll_has_elements(const LLIST *l); // returns first obj if has one 81 80 void *ll_last_element(const LLIST *l); 82 81 int32_t ll_contains(const LLIST *l, const void *obj);
Note:
See TracChangeset
for help on using the changeset viewer.