X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilclist.h;h=66efd22fa7dd8667df1280a8ccff30a06e0464bc;hb=30b8fb532138b2d9b523d3c069724e78fb72f8e3;hp=ec4d7be15fea364d49d1ba32e4dfafdbd828aeef;hpb=997c86f73e8f75d7b0055e4959e88937c3bf8419;p=silc.git diff --git a/lib/silcutil/silclist.h b/lib/silcutil/silclist.h index ec4d7be1..66efd22f 100644 --- a/lib/silcutil/silclist.h +++ b/lib/silcutil/silclist.h @@ -21,12 +21,25 @@ * * DESCRIPTION * - * Implementation of the SilcList interface. This interface provides - * simple linked list. This interface does not allocate any memory. + * Generic list interface that can turn any structure with list pointers + * into a SilcList. The interface can provide both singly and doubly linked + * lists. The interface does not allocate any memory. * * SILC List is not thread-safe. If the same list context must be used * in multithreaded environment concurrency control must be employed. * + * EXAMPLE + * + * struct EntryStruct { + * char *dummy; + * struct EntryStruct *next; // The list member pointer + * }; + * + * SilcList list; + * + * // Initialize list + * silc_list_init(list, struct EntryStruct, next); + * ***/ #ifndef SILCLIST_H @@ -44,7 +57,7 @@ * function silc_list_init. * ***/ -typedef struct { +typedef struct SilcListStruct { void *head; /* Start of the list */ void *tail; /* End of the list */ void *current; /* Current pointer in list */ @@ -104,6 +117,7 @@ do { \ (list).next_offset = silc_offsetof(type, nextfield); \ (list).prev_set = 0; \ (list).prev_offset = 0; \ + (list).end_set = 0; \ (list).head = (list).tail = (list).current = NULL; \ } while(0) @@ -143,6 +157,7 @@ do { \ (list).next_offset = silc_offsetof(type, nextfield); \ (list).prev_offset = silc_offsetof(type, prevfield); \ (list).prev_set = 1; \ + (list).end_set = 0; \ (list).head = (list).tail = (list).current = NULL; \ } while(0)