GRU - Generic Reusable Utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
gru_node.h
Go to the documentation of this file.
1 /*
2  Copyright 2016 Otavio Rodolfo Piske
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16 
17 #ifndef NODE_H
18 #define NODE_H
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 
23 #include "common/gru_portable.h"
24 
25 typedef struct gru_node_t_ {
26  struct gru_node_t_ *next;
28  const void *data;
29 } gru_node_t;
30 
36 gru_export gru_node_t *gru_node_new(const void *ptr);
37 
43 
51 
59 
65 
71 
72 #define gru_node_get_data_ptr(type, node) (type *) node->data
73 #define gru_node_get_data(type, node) (*(gru_node_get_data_ptr(type, node)))
74 
75 #endif
#define gru_restrict
Definition: gru_portable.h:20
Definition: gru_node.h:25
struct gru_node_t_ * previous
Definition: gru_node.h:27
#define gru_export
Definition: gru_portable.h:19
void gru_node_unlink(gru_node_t *node)
Definition: gru_node.c:68
struct gru_node_t_ gru_node_t
gru_node_t * gru_node_new(const void *ptr)
Creates a new node.
Definition: gru_node.c:18
const void * data
Definition: gru_node.h:28
void gru_node_reset(gru_node_t *node)
Definition: gru_node.c:63
void gru_node_set_previous(gru_node_t *node, gru_node_t *previous)
Definition: gru_node.c:40
struct gru_node_t_ * next
Definition: gru_node.h:26
void gru_node_destroy(gru_node_t **node)
Destroys a node and sets is address to NULL.
Definition: gru_node.c:33
void gru_node_set_next(gru_node_t *node, gru_node_t *next)
Definition: gru_node.c:52