XenevaOS
Loading...
Searching...
No Matches
Classes | Functions
stack.c File Reference
#include <inttypes.h>
#include <string.h>
#include <parserutils/utils/stack.h>
#include <stdio.h>
Include dependency graph for stack.c:

Classes

struct  parserutils_stack
 

Functions

parserutils_error parserutils_stack_create (size_t item_size, size_t chunk_size, parserutils_stack **stack)
 
parserutils_error parserutils_stack_destroy (parserutils_stack *stack)
 
parserutils_error parserutils_stack_push (parserutils_stack *stack, const void *item)
 
parserutils_error parserutils_stack_pop (parserutils_stack *stack, void *item)
 
void * parserutils_stack_get_current (parserutils_stack *stack)
 
void parserutils_stack_dump (parserutils_stack *stack, const char *prefix, void(*printer)(void *item))
 

Function Documentation

◆ parserutils_stack_create()

parserutils_error parserutils_stack_create ( size_t  item_size,
size_t  chunk_size,
parserutils_stack **  stack 
)

Create a stack

Parameters
item_sizeLength, in bytes, of an item in the stack
chunk_sizeNumber of stack slots in a chunk
stackPointer to location to receive stack instance
Returns
PARSERUTILS_OK on success, PARSERUTILS_BADPARM on bad parameters PARSERUTILS_NOMEM on memory exhaustion

◆ parserutils_stack_destroy()

parserutils_error parserutils_stack_destroy ( parserutils_stack *  stack)

Destroy a stack instance

Parameters
stackThe stack to destroy
Returns
PARSERUTILS_OK on success, appropriate error otherwise.

◆ parserutils_stack_dump()

void parserutils_stack_dump ( parserutils_stack *  stack,
const char *  prefix,
void(*)(void *item)  printer 
)
extern

◆ parserutils_stack_get_current()

void * parserutils_stack_get_current ( parserutils_stack *  stack)

Retrieve a pointer to the current item on the stack

Parameters
stackThe stack to inspect
Returns
Pointer to item on stack, or NULL if none

◆ parserutils_stack_pop()

parserutils_error parserutils_stack_pop ( parserutils_stack *  stack,
void *  item 
)

Pop an item off a stack

Parameters
stackThe stack to pop from
itemPointer to location to receive popped item, or NULL
Returns
PARSERUTILS_OK on success, appropriate error otherwise.

◆ parserutils_stack_push()

parserutils_error parserutils_stack_push ( parserutils_stack *  stack,
const void *  item 
)

Push an item onto the stack

Parameters
stackThe stack to push onto
itemThe item to push
Returns
PARSERUTILS_OK on success, appropriate error otherwise