regfi
Functions
void_stack.c File Reference
Include dependency graph for void_stack.c:

Functions

void_stackvoid_stack_new (unsigned short max_size)
 Allocates a new void_stack. More...
 
void_stackvoid_stack_copy (const void_stack *v)
 Makes a shallow copy of void_stack. More...
 
void_stackvoid_stack_copy_reverse (const void_stack *v)
 Makes a shallow copy of void_stack in reverse order. More...
 
void void_stack_free (void_stack *stack)
 Frees the memory associated with a void_stack, but not the elements held on the stack. More...
 
void void_stack_free_deep (void_stack *stack)
 Frees the memory associated with a void_stack and the elements referenced by the stack. More...
 
unsigned short void_stack_size (const void_stack *stack)
 Query the current number of elements on a void_stack() More...
 
void * void_stack_pop (void_stack *stack)
 Removes the top element on a void_stack and returns a reference to it. More...
 
bool void_stack_push (void_stack *stack, void *e)
 Puts a new element on the top of a void_stack. More...
 
const void * void_stack_cur (const void_stack *stack)
 Returns a pointer to the current element on the top of the stack. More...
 
void_stack_iteratorvoid_stack_iterator_new (const void_stack *stack)
 Creates a new iterator for the specified void_stack. More...
 
void void_stack_iterator_free (void_stack_iterator *iter)
 Frees a void_stack_iterator. More...
 
const void * void_stack_iterator_next (void_stack_iterator *iter)
 Returns a pointer to the the next element in the stack. More...
 

Function Documentation

◆ void_stack_new()

void_stack* void_stack_new ( unsigned short  max_size)

Allocates a new void_stack.

Parameters
max_sizethe maxiumum number of elements which may be pushed onto the stack.
Returns
a pointer to the newly allocated void_stack, or NULL if an error occurred.

Referenced by regfi_iterator_new(), void_stack_copy(), and void_stack_copy_reverse().

◆ void_stack_copy()

void_stack* void_stack_copy ( const void_stack v)

Makes a shallow copy of void_stack.

Parameters
vthe stack to make a copy of.
Returns
a pointer to the duplicate void_stack, or NULL if an error occurred.

References void_stack_new().

◆ void_stack_copy_reverse()

void_stack* void_stack_copy_reverse ( const void_stack v)

Makes a shallow copy of void_stack in reverse order.

Parameters
vthe stack to make a copy of.
Returns
a pointer to the duplicate void_stack (which will be in reverse order), or NULL if an error occurred.

References void_stack_new().

◆ 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.

Parameters
stackthe stack to be free()d.

◆ 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.


Do not use this function if the elements of the stack are also free()d elsewhere, or contain pointers to other memory which cannot be otherwise free()d.

Parameters
stackthe stack to be free()d.

◆ void_stack_size()

unsigned short void_stack_size ( const void_stack stack)

Query the current number of elements on a void_stack()

Parameters
stackthe void_stack to query
Returns
the number of elements currently on the stack.

Referenced by regfi_iterator_ancestry().

◆ void_stack_pop()

void* void_stack_pop ( void_stack stack)

Removes the top element on a void_stack and returns a reference to it.

Parameters
stackthe void_stack to pop
Returns
a pointer to the popped stack element, or NULL if no elements exist on the stack.

Referenced by regfi_iterator_up().

◆ void_stack_push()

bool void_stack_push ( void_stack stack,
void *  e 
)

Puts a new element on the top of a void_stack.

Parameters
stackthe void_stack being modified.
ethe element to be added
Returns
true if the element was successfully added, false otherwise.

Referenced by regfi_iterator_down().

◆ 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.

Parameters
stackthe void_stack being queried.
Returns
a pointer to the current element on the top of the stack, or NULL if no elements exist in the stack.

◆ void_stack_iterator_new()

void_stack_iterator* void_stack_iterator_new ( const void_stack stack)

Creates a new iterator for the specified void_stack.

Parameters
stackthe void_stack to be referenced by the new iterator
Returns
a new void_stack_iterator, or NULL if an error occurred.

Referenced by regfi_iterator_ancestry().

◆ void_stack_iterator_free()

void void_stack_iterator_free ( void_stack_iterator iter)

Frees a void_stack_iterator.

Does not affect the void_stack referenced by the iterator.

Parameters
iterthe void_stack_iterator to be free()d.

Referenced by regfi_iterator_ancestry().

◆ 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.

Iterates over elements starting in order from the oldest element (bottom of the stack).

Parameters
iterthe void_stack_iterator used to lookup the next element.
Returns
a pointer to the next element.

Referenced by regfi_iterator_ancestry().