MGE General C Library - API Documentation
v1.4.1
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 "sllist-internal.h"
#include <mge-errno.h>
#include <sllist.h>
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... | |
struct sllistnode * | free_sllist (struct sllistnode *head) |
Free the entire list. More... | |
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
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. |
struct sllistnode* free_sllist | ( | struct sllistnode * | head | ) |
Free the entire list.
Walks the list deleting nodes.
head | The root node. |