void_stack.h
Go to the documentation of this file.
/*
* Copyright (C) 2005,2007,2009-2010 Timothy D. Morgan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id$
*/
#ifndef _VOID_STACK_H
#define _VOID_STACK_H
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <talloc.h>
#include "compat.h"
typedef struct _void_stack
{
void** elements;
unsigned short max_size;
unsigned short top;
} void_stack;
typedef struct _void_stack_iterator
{
const void_stack* stack;
unsigned short cur;
} void_stack_iterator;
_EXPORT()
void_stack* void_stack_new(unsigned short max_size);
_EXPORT()
void_stack* void_stack_copy(const void_stack* v);
_EXPORT()
void_stack* void_stack_copy_reverse(const void_stack* v);
_EXPORT()
void void_stack_free(void_stack* stack);
_EXPORT()
void void_stack_free_deep(void_stack* stack);
_EXPORT()
unsigned short void_stack_size(const void_stack* stack);
_EXPORT()
void* void_stack_pop(void_stack* stack);
_EXPORT()
bool void_stack_push(void_stack* stack, void* e);
_EXPORT()
const void* void_stack_cur(const void_stack* stack);
_EXPORT()
void_stack_iterator* void_stack_iterator_new(const void_stack* stack);
_EXPORT()
void void_stack_iterator_free(void_stack_iterator* iter);
_EXPORT()
const void* void_stack_iterator_next(void_stack_iterator* iter);
/* XXX: for completeness, might want to add a void_stack_iterator_first()
* function, to return iterator to first element
*/
#endif
void_stack_iterator_free
void void_stack_iterator_free(void_stack_iterator *iter)
Frees a void_stack_iterator.
Definition: void_stack.c:167
void_stack
XXX: document this.
Definition: void_stack.h:39
void_stack_pop
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
void_stack_copy
void_stack * void_stack_copy(const void_stack *v)
Makes a shallow copy of void_stack.
Definition: void_stack.c:53
void_stack_push
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_iterator
XXX: document this.
Definition: void_stack.h:48
void_stack_cur
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_new
void_stack * void_stack_new(unsigned short max_size)
Allocates a new void_stack.
Definition: void_stack.c:27
void_stack_free_deep
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_stack_free
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_stack_copy_reverse
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_stack_iterator_next
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
void_stack_size
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_iterator_new
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