MGE General C Library - API Documentation  v1.3.5
Library of general C functions.
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 "dllist-internal.h"
#include <dllist.h>
#include <mge-errno.h>
Include dependency graph for dllist.c:

Functions

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

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-2020 Mark Grant

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

Version
v1.0.11 ==== 29/06/2020

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_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