X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/d0fd08fab7a646c47fae21491c8d8f1c2b790a2c..d38e1f468376f8b19b208f2da4d20cb2919875dd:/ll.h diff --git a/ll.h b/ll.h index fcdbc5a..8360eab 100644 --- a/ll.h +++ b/ll.h @@ -1,5 +1,6 @@ -/* - * ll.h - various things of used for dealing with linked lists. +/** + * @file ll.h + * @brief Various things of used for dealing with linked lists. * * Copyright 2000-2004 Jonathan McDowell * @@ -20,6 +21,9 @@ #ifndef __LL_H__ #define __LL_H__ +/** + * @brief Take a packet and add it to a linked list + */ #define ADD_PACKET_TO_LIST_END(list, name, item) \ if (list->name##s != NULL) { \ list->last_##name->next = malloc(sizeof (*list->last_##name));\ @@ -31,6 +35,11 @@ memset(list->last_##name, 0, sizeof(*list->last_##name)); \ list->last_##name->packet = item; +/** + * @brief Add an item to the end of a linked list + * @param list A pointer to the last element in the list + * @param item the item to add + */ #define ADD_PACKET_TO_LIST(list, item) \ if (list != NULL) { \ list->next = malloc(sizeof (*list)); \ @@ -42,74 +51,74 @@ list->packet = item; /** - * struct ll - A generic linked list structure. - * @object: The object. - * @next: A pointer to the next object. + * @brief A generic linked list structure. */ struct ll { + /** The object. */ void *object; + /** A pointer to the next object. */ struct ll *next; }; /** - * lladd - Add an item to a linked list. - * @curll: The list to add to. Can be NULL to create a new list. - * @object: The object to add. + * @brief Add an item to a linked list. + * @param curll The list to add to. Can be NULL to create a new list. + * @param object The object to add. * - * Returns a pointer to the head of the new list. + * Returns a pointer to the head of the new list. */ struct ll *lladd(struct ll *curll, void *object); /** - * lladdend - Add an item to the end of a linked list. - * @curll: The list to add to. Can be NULL to create a new list. - * @object: The object to add. + * @brief Add an item to the end of a linked list. + * @param curll The list to add to. Can be NULL to create a new list. + * @param object The object to add. * - * Returns a pointer to the head of the new list. + * Returns a pointer to the head of the new list. */ struct ll *lladdend(struct ll *curll, void *object); /** - * lldel - Remove an item from a linked list. - * @curll: The list to remove the item from. - * @object: The object to remove. - * @objectcmp: A pointer to a comparision function for the object type. + * @brief Remove an item from a linked list. + * @param curll The list to remove the item from. + * @param object The object to remove. + * @param objectcmp A pointer to a comparision function for the object type. * - * Trawls through the list looking for the object. If it's found then it - * is removed from the list. Only one occurance is searched for. Returns - * a pointer to the head of the new list. + * Trawls through the list looking for the object. If it's found then it + * is removed from the list. Only one occurance is searched for. Returns + * a pointer to the head of the new list. */ struct ll *lldel(struct ll *curll, void *object, int (*objectcmp) (const void *object1, const void *object2)); /** - * llfind - Find an item in a linked list. - * @curll: The list to look in. - * @object: The object to look for. - * @objectcmp: A pointer to a comparision function for the object type. + * @brief Find an item in a linked list. + * @param curll The list to look in. + * @param object The object to look for. + * @param objectcmp A pointer to a comparision function for the object type. * - * Searches through a list for an object. Returns a pointer to the object - * if it's found, otherwise NULL. + * Searches through a list for an object. Returns a pointer to the object + * if it's found, otherwise NULL. */ struct ll *llfind(struct ll *curll, void *object, int (*objectcmp) (const void *object1, const void *object2)); /** - * llsize - Returns the number of elements in a linked list. - * @curll: The linked list to count. + * @brief Returns the number of elements in a linked list. + * @param curll The linked list to count. * - * Counts the number of elements in a linked list. + * Counts the number of elements in a linked list. */ unsigned long llsize(struct ll *curll); /** - * llfree - Frees a linked list. - * @curll: The list to free. - * @objectfree: A pointer to a free function for the object. + * @brief Frees a linked list. + * @param curll The list to free. + * @param objectfree A pointer to a free function for the object. * - * Walks through a list and free it. If a function is provided for - * objectfree then it's called for each element to free them, if it's NULL - * just the list is freed. + * Walks through a list and free it. If a function is provided for + * objectfree then it's called for each element to free them, if it's NULL + * just the list is freed. */ void llfree(struct ll *curll, void (*objectfree) (void *object));