sphore 0.0.1
SPH openGL rendering engine
|
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_t * | node_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_t * | node_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. |
Code for generic list nodes, used by list.c.
typedef unsigned int _SREnodeID |
A unique identifier given to each node in a list.
Access to the list node.
Memory management with node_create and node_destroy.
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.
[in] | id | The id for the new node. |
[in] | data | The data for the new node. |
[in] | next | The node that comes after 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.
[in] | node | The node to be destroyed. |
void node_destroy_data | ( | node_t * | node, |
void(*)(void *) | destroy_func | ||
) |
Destroys a node and the accosiated data.
[in] | node | The node to be destroyed. |
[in] | destroy_func | The 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.
[in] | node | The node to query. |
_SREnodeID node_get_id | ( | node_t * | node | ) |
Gets the id of the given node.
[in] | node | The node to query. |
Gets the node that comes after the given node.
[in] | node | The node to query. |