|
MGE General C Library - API Documentation v1.9.0
Library of general C functions.
|
Builds, traverses and releases a singly linked list. More...
#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <libmgec/mge-errno.h>#include <libmgec/sllist.h>
Functions | |
| static void | free_sll_node (struct sllistnode *currentnode) |
| struct sllistnode * | add_head_sll_node (struct sllistnode *head, const void *object, size_t objsize) |
| Add a node to the start of the singly linked list. | |
| struct sllistnode * | add_tail_sll_node (struct sllistnode *head, const void *object, size_t objsize) |
| Add a node to the tail of the singly linked list. | |
| void * | find_sll_node (struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *)) |
| Find a node. | |
| struct sllistnode * | free_sllist (struct sllistnode *head) |
| Free the entire list. | |
Builds, traverses and releases a singly linked list.
Build, manipulate and traverse functionality for singly linked lists.
Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0-only
| struct sllistnode * add_head_sll_node | ( | struct sllistnode * | head, |
| const void * | object, | ||
| size_t | objsize | ||
| ) |
Add a node to the start of the singly linked list.
On error mge_errno will be set.
| head | A pointer to the current root node or NULL if the list is not yet started. |
| object | The object to attach to the node. |
| objsize | The size of the attached object. |
| struct sllistnode * add_tail_sll_node | ( | struct sllistnode * | head, |
| const void * | object, | ||
| size_t | objsize | ||
| ) |
Add a node to the tail of the singly linked list.
On error mge_errno will be set.
| head | A pointer to the root node or NULL if the list is not yet started. |
| object | The object to attach to the node. |
| objsize | The size of the attached object. |
| void * find_sll_node | ( | struct sllistnode * | head, |
| const void * | searchobj, | ||
| int(*)(const void *, const void *) | comp | ||
| ) |
Find a node.
On error mge_errno will be set, otherwise it will be 0.
| head | A pointer to the current root node. |
| searchobj | The object to find. It does not need to be a fully populated object. It only needs enough inforamtion to support the comparison function, eg a key. |
| comp | A pointer to the comparison function to be used. This must have the same shape as strcmp. |
|
static |
| struct sllistnode * free_sllist | ( | struct sllistnode * | head | ) |
Free the entire list.
Walks the list deleting nodes.
| head | The root node. |