X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcdlist.h;h=a27aaad41ca86fd5f9139a986e53fe3bf10e8322;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=54c2a8bacadb402631bedf481c26df8ab9cde5e3;hpb=e8504852258db5a63e542246b64c23f8b8624006;p=silc.git diff --git a/lib/silcutil/silcdlist.h b/lib/silcutil/silcdlist.h index 54c2a8ba..a27aaad4 100644 --- a/lib/silcutil/silcdlist.h +++ b/lib/silcutil/silcdlist.h @@ -27,7 +27,7 @@ * DESCRIPTION * * SILC Dynamic List API can be used to add opaque contexts to list that - * will automatically allocate list entries. Normal SILC List API cannot + * will automatically allocate list entries. The simpler SilcList cannot * be used for this purpose because in that case the context passed to the * list must be defined as list structure already. This is not the case in * SilcDList. But SilcDList is a bit slower than SilcList because it @@ -36,6 +36,21 @@ * SILC Dynamic List is not thread-safe. If the same list context must be * used in multithreaded environment concurrency control must be employed. * + * EXAMPLE + * + * SilcDList list = silc_dlist_init(); + * + * silc_dlist_add(list, entry1); + * silc_dlist_add(list, entry2); + * + * // Traverse the list from the beginning to the end + * silc_dlist_start(list) + * while ((entry = silc_dlist_get(list)) != SILC_LIST_END) { + * ... + * } + * + * silc_dlist_uninit(list); + * ***/ /****s* silcutil/SilcDListAPI/SilcDList @@ -75,7 +90,8 @@ typedef struct SilcDListEntryStruct { * * DESCRIPTION * - * Initializes SilcDList. Returns the SilcDList context or NULL on error. + * Initializes SilcDList. Returns the SilcDList context or NULL if system + * is out of memory. * ***/ @@ -87,7 +103,7 @@ SilcDList silc_dlist_init(void) list = (SilcDList)silc_malloc(sizeof(*list)); if (!list) return NULL; - list->current = list->prev = NULL; + list->stack = list->current = list->prev = NULL; silc_list_init_prev(list->list, struct SilcDListEntryStruct, next, prev); return list;