GRU - Generic Reusable Utilities
Loading...
Searching...
No Matches
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
25typedef struct gru_node_t_ {
28 const void *data;
30
36gru_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
struct gru_node_t_ gru_node_t
gru_export gru_node_t * gru_node_new(const void *ptr)
Creates a new node.
Definition: gru_node.c:18
gru_export void gru_node_set_next(gru_node_t *gru_restrict node, gru_node_t *gru_restrict next)
Sets the next node for a given node.
gru_export void gru_node_reset(gru_node_t *gru_restrict node)
Reset the pointers for the node and unassign the next and previous pointers.
gru_export void gru_node_destroy(gru_node_t **node)
Destroys a node and sets is address to NULL.
Definition: gru_node.c:33
gru_export void gru_node_set_previous(gru_node_t *gru_restrict node, gru_node_t *gru_restrict previous)
Sets the previous node for a given node.
gru_export void gru_node_unlink(gru_node_t *gru_restrict node)
Unlink a node from it's previous and next node and resets it.
#define gru_restrict
Definition: gru_portable.h:20
#define gru_export
Definition: gru_portable.h:19
Definition: gru_node.h:25
struct gru_node_t_ * next
Definition: gru_node.h:26
struct gru_node_t_ * previous
Definition: gru_node.h:27
const void * data
Definition: gru_node.h:28