Loading...
Searching...
No Matches
void_stack.h File Reference

This is a very simple implementation of a stack which stores chunks of memory of any type. More...

Include dependency graph for void_stack.h:

Go to the source code of this file.

## Data Structures

struct | void_stack
| XXX: document this. More...
struct | void_stack_iterator
| XXX: document this. More...

## Functions

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

## Detailed Description

This is a very simple implementation of a stack which stores chunks of memory of any type.

## Function Documentation

## void_stack_new()

void_stack * void_stack_new | ( | unsigned short | max_size | ) |

Allocates a new void_stack.

Parameters

  max_size | the 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

  v | the 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

  v | the 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

  stack | the 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

  stack | the 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

  stack | the 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

  stack | the 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

  stack | the void_stack being modified.
  e | the 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

  stack | the 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

  stack | the 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

  iter | the 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

  iter | the void_stack_iterator used to lookup the next element.

Returns
  a pointer to the next element.

Referenced by regfi_iterator_ancestry().