regfi
Loading...
Searching...
No Matches
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
39typedef struct _void_stack
40{
41 void** elements;
42 unsigned short max_size;
43 unsigned short top;
45
46
48typedef struct _void_stack_iterator
49{
50 const void_stack* stack;
51 unsigned short cur;
53
54
63_EXPORT()
64void_stack* void_stack_new(unsigned short max_size);
65
66
73_EXPORT()
75
76
84_EXPORT()
86
87
93_EXPORT()
94void void_stack_free(void_stack* stack);
95
96
106_EXPORT()
108
109
116_EXPORT()
117unsigned short void_stack_size(const void_stack* stack);
118
119
127_EXPORT()
128void* void_stack_pop(void_stack* stack);
129
130
138_EXPORT()
139bool void_stack_push(void_stack* stack, void* e);
140
141
149_EXPORT()
150const 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
XXX: document this.
Definition void_stack.h:49
XXX: document this.
Definition void_stack.h:40
void_stack_iterator * void_stack_iterator_new(const void_stack *stack)
Creates a new iterator for the specified void_stack.
Definition void_stack.c:149
const void * void_stack_iterator_next(void_stack_iterator *iter)
Returns a pointer to the the next element in the stack.
Definition void_stack.c:173
unsigned short void_stack_size(const void_stack *stack)
Query the current number of elements on a void_stack()
Definition void_stack.c:106
void_stack * void_stack_new(unsigned short max_size)
Allocates a new void_stack.
Definition void_stack.c:27
const void * void_stack_cur(const void_stack *stack)
Returns a pointer to the current element on the top of the stack.
Definition void_stack.c:138
void_stack * void_stack_copy(const void_stack *v)
Makes a shallow copy of void_stack.
Definition void_stack.c:53
bool void_stack_push(void_stack *stack, void *e)
Puts a new element on the top of a void_stack.
Definition void_stack.c:126
void_stack * void_stack_copy_reverse(const void_stack *v)
Makes a shallow copy of void_stack in reverse order.
Definition void_stack.c:72
void void_stack_free(void_stack *stack)
Frees the memory associated with a void_stack, but not the elements held on the stack.
Definition void_stack.c:91
void void_stack_iterator_free(void_stack_iterator *iter)
Frees a void_stack_iterator.
Definition void_stack.c:167
void void_stack_free_deep(void_stack *stack)
Frees the memory associated with a void_stack and the elements referenced by the stack.
Definition void_stack.c:97
void * void_stack_pop(void_stack *stack)
Removes the top element on a void_stack and returns a reference to it.
Definition void_stack.c:112