MGE General C Library - API Documentation v1.8.4
Library of general C functions.
Loading...
Searching...
No Matches
dllist.c File Reference

Builds, traverses and releases a doubly linked list. More...

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libmgec/dllist.h>
#include <libmgec/mge-errno.h>
Include dependency graph for dllist.c:

Functions

static void free_dll_node (struct dllistnode *currentnode)
 
struct dllistnodeadd_dll_node (struct dllistnode *currentnode, const void *object, size_t objsize)
 Add a node to the tail of the doubly linked list.
 
struct dllistnodefree_dllist (struct dllistnode *currentnode)
 Free the entire list.
 

Detailed Description

Builds, traverses and releases a doubly linked list.

Build, manipulate and bi-directional traverse functionality for doubly linked lists.

Author
Copyright (C) 2016-2023 Mark Grant

Released under the GPLv3 only.
SPDX-License-Identifier: GPL-3.0-only

Version
v1.1.0 ==== 02/11/2023

Function Documentation

◆ add_dll_node()

struct dllistnode * add_dll_node ( struct dllistnode currentnode,
const void *  object,
size_t  objsize 
)

Add a node to the tail of the doubly linked list.

On error mge_errno will be set.

Parameters
currentnodeA pointer to the first node or NULL if list not yet started.
objectObject to be attached to the node.
objsizeSize of object.
Returns
A pointer to the first node. Returns NULL on error.

◆ free_dll_node()

static void free_dll_node ( struct dllistnode currentnode)
static

◆ free_dllist()

struct dllistnode * free_dllist ( struct dllistnode currentnode)

Free the entire list.

Remove all nodes and free memory allocated to the dllist. Walks the list deleting nodes.

Parameters
currentnodeThe root node.
Returns
NULL