Generic stack.  
More...
Go to the source code of this file.
|  | 
| #define | stack_new(compare,  free,  pool)   slist_new(compare, free, pool) | 
|  | 
| #define | stack_init(stack,  compare,  free,  pool)   slist_init(stack, compare, free, pool) | 
|  | 
| #define | stack_destroy(stack)   slist_destroy(stack) | 
|  | 
| #define | stack_free(stack)   slist_free(stack) | 
|  | 
| #define | stack_push(stack,  data)   slist_prepend(stack, data) | 
|  | 
| #define | stack_clear(stack)   slist_clear(stack) | 
|  | 
| #define | stack_count(stack)   slist_count(stack) | 
|  | 
◆ stack_clear
- Parameters
- 
  
  
Clears a stack. 
Definition at line 104 of file stack.h.
 
 
◆ stack_count
- Parameters
- 
  
  
- Returns
- number of items
Gets the number of stored items. 
Definition at line 112 of file stack.h.
 
 
◆ stack_destroy
- Parameters
- 
  
  
Frees all items in the stack and the stack pointer. 
Definition at line 64 of file stack.h.
 
 
◆ stack_free
- Parameters
- 
  
  
Frees all items in the stack without freeing the stack pointer. 
Definition at line 71 of file stack.h.
 
 
◆ stack_init
      
        
          | #define stack_init | ( |  | stack, | 
        
          |  |  |  | compare, | 
        
          |  |  |  | free, | 
        
          |  |  |  | pool | 
        
          |  | ) |  | slist_init(stack, compare, free, pool) | 
      
 
- Parameters
- 
  
    | stack | a Stack |  | compare | function to compare item data |  | free | function to free item data or NULL |  | pool | a user-defined memory pool for creating/destroying StackItems or NULL |  
 
Initializes a Stack. 
Definition at line 57 of file stack.h.
 
 
◆ stack_new
      
        
          | #define stack_new | ( |  | compare, | 
        
          |  |  |  | free, | 
        
          |  |  |  | pool | 
        
          |  | ) |  | slist_new(compare, free, pool) | 
      
 
- Parameters
- 
  
    | compare | function to compare item data |  | free | function to free item data or NULL |  | pool | a user-defined memory pool for creating/destroying StackItems or NULL |  
 
- Returns
- a new Stack
Creates a new Stack. 
Definition at line 47 of file stack.h.
 
 
◆ stack_push
- Parameters
- 
  
    | stack | a Stack |  | data | data to push |  
 
Pushs data onto the stack. 
Definition at line 79 of file stack.h.
 
 
◆ Stack
Generic stack. 
Definition at line 31 of file stack.h.
 
 
◆ StackItem
Holds stack item data & pointer to next element. 
Definition at line 37 of file stack.h.
 
 
◆ stack_head()
      
        
          | bool stack_head | ( | const Stack * | stack, | 
        
          |  |  | void ** | data | 
        
          |  | ) |  |  | 
      
 
- Parameters
- 
  
    | stack | a Stack |  | data | location to store data |  
 
- Returns
- true if stack is not empty
Gets first element from stack without removing it. 
Definition at line 55 of file stack.c.
 
 
◆ stack_pop()
      
        
          | bool stack_pop | ( | Stack * | stack, | 
        
          |  |  | void ** | data | 
        
          |  | ) |  |  | 
      
 
- Parameters
- 
  
    | stack | a Stack |  | data | location to store data |  
 
- Returns
- true if stack is not empty
Pops the first element from the stack. 
Definition at line 28 of file stack.c.