regfi
 All Data Structures Files Functions Variables Groups Pages
void_stack.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005,2007,2009-2010 Timothy D. Morgan
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: void_stack.h 253 2011-06-13 02:27:42Z tim $
18  */
19 
28 #ifndef _VOID_STACK_H
29 #define _VOID_STACK_H
30 
31 #include <stdlib.h>
32 #include <stdbool.h>
33 #include <string.h>
34 #include <talloc.h>
35 
36 #include "compat.h"
37 
39 typedef struct _void_stack
40 {
41  void** elements;
42  unsigned short max_size;
43  unsigned short top;
44 } void_stack;
45 
46 
48 typedef struct _void_stack_iterator
49 {
50  const void_stack* stack;
51  unsigned short cur;
53 
54 
63 _EXPORT()
64 void_stack* void_stack_new(unsigned short max_size);
65 
66 
73 _EXPORT()
75 
76 
84 _EXPORT()
86 
87 
93 _EXPORT()
94 void void_stack_free(void_stack* stack);
95 
96 
106 _EXPORT()
107 void void_stack_free_deep(void_stack* stack);
108 
109 
116 _EXPORT()
117 unsigned short void_stack_size(const void_stack* stack);
118 
119 
127 _EXPORT()
128 void* void_stack_pop(void_stack* stack);
129 
130 
138 _EXPORT()
139 bool void_stack_push(void_stack* stack, void* e);
140 
141 
149 _EXPORT()
150 const void* void_stack_cur(const void_stack* stack);
151 
152 
159 _EXPORT()
161 
162 
169 _EXPORT()
171 
172 
181 _EXPORT()
183 
184 
185 /* XXX: for completeness, might want to add a void_stack_iterator_first()
186  * function, to return iterator to first element
187  */
188 #endif