MGE General C Library - Full Internal Documentation
v1.4.1
Library of general C functions.
|
Singly linked list header file. More...
#include <portability.h>
Go to the source code of this file.
Data Structures | |
struct | sllistnode |
Singly linked list node. More... | |
Macros | |
#define | for_each_sll_node(focus, head) for (focus = head; focus != NULL; focus = focus->next) |
Iterate over the list. More... | |
Functions | |
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. More... | |
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. More... | |
void * | find_sll_node (struct sllistnode *head, const void *searchobj, int(*comp)(const void *, const void *)) |
Find a node. More... | |
static struct sllistnode * | find_next_sll_node (struct sllistnode *focus) |
Find the next node in the list. More... | |
struct sllistnode * | free_sllist (struct sllistnode *head) |
Free the entire list. More... | |
Singly linked list header file.
Header file for singly linked lists in the libmgec shared library.
Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0
#define for_each_sll_node | ( | focus, | |
head | |||
) | for (focus = head; focus != NULL; focus = focus->next) |
Iterate over the list.
focus | The current node in focus. |
head | The head of the list. |
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. |
|
static |
Find the next node in the list.
focus | The current node. |
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. |
struct sllistnode* free_sllist | ( | struct sllistnode * | head | ) |
Free the entire list.
Walks the list deleting nodes.
head | The root node. |