sphore 0.0.1
SPH openGL rendering engine

src/node.h File Reference

Code for generic list nodes, used by list.c. More...

Go to the source code of this file.

Typedefs

typedef unsigned int _SREnodeID
 A unique identifier given to each node in a list.
typedef struct _node node_t
 Access to the list node.

Functions

node_tnode_create (_SREnodeID id, void *data, node_t *next)
 Creates a new list node.
void node_destroy (node_t *node)
 Destroys a node.
void node_destroy_data (node_t *node, void(*destroy_func)(void *))
 Destroys a node and the accosiated data.
node_tnode_get_next (node_t *node)
 Gets the node that comes after the given node.
_SREnodeID node_get_id (node_t *node)
 Gets the id of the given node.
void * node_get_data (node_t *node)
 Gets the data of the given node.
void node_set_next (node_t *node, node_t *new_next)
 Changes the next node for the given node.

Detailed Description

Code for generic list nodes, used by list.c.


Typedef Documentation

typedef unsigned int _SREnodeID

A unique identifier given to each node in a list.

typedef struct _node node_t

Access to the list node.

Memory management with node_create and node_destroy.


Function Documentation

node_t* node_create ( _SREnodeID  id,
void *  data,
node_t next 
)

Creates a new list node.

The node should be cleaned up by node_destroy.

Parameters:
[in]idThe id for the new node.
[in]dataThe data for the new node.
[in]nextThe node that comes after the new node.
Returns:
A pointer to the new node.
void node_destroy ( node_t node)

Destroys a node.

This functino does not destroy the data accosiacted with the node, to do this you must use node_destroy_data.

Parameters:
[in]nodeThe node to be destroyed.
void node_destroy_data ( node_t node,
void(*)(void *)  destroy_func 
)

Destroys a node and the accosiated data.

Parameters:
[in]nodeThe node to be destroyed.
[in]destroy_funcThe function used to clean up the data.

Frees the given node aswell as the data ascociated with it using the destroy function.

void* node_get_data ( node_t node)

Gets the data of the given node.

Parameters:
[in]nodeThe node to query.
Returns:
the data of the given of node.
_SREnodeID node_get_id ( node_t node)

Gets the id of the given node.

Parameters:
[in]nodeThe node to query.
Returns:
The id of the node.
node_t* node_get_next ( node_t node)

Gets the node that comes after the given node.

Parameters:
[in]nodeThe node to query.
Returns:
A pointer to the next node.
void node_set_next ( node_t node,
node_t new_next 
)

Changes the next node for the given node.

Parameters:
[in]nodeThe node to modify.
[in]next_nodeThe new next node.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines