Contiki-NG
|
Macros | |
#define | STACK(name) LIST(name) |
Define a stack. | |
Typedefs | |
typedef list_t | stack_t |
The stack data type. | |
Functions | |
static void | stack_init (stack_t stack) |
Initialise a stack. | |
static void | stack_push (stack_t stack, void *element) |
Adds an element to the top of the stack. | |
static void * | stack_pop (stack_t stack) |
Removes the top element from the stack. | |
static void * | stack_peek (stack_t stack) |
Returns the top element of the stack, without popping it. | |
static bool | stack_is_empty (stack_t stack) |
Check if a stack is empty. | |
This library provides functions for the creation and manipulation of stacks. The library is implemented as a wrapper around the list library.
A stack is declared using the STACK macro. Stack elements must be allocated by the calling code and must be of a C struct datatype. In this struct, the first field must be a pointer called next. This field will be used by the library to maintain the stack. Application code must not modify this field directly.
This library is not safe to be used within an interrupt context.
#define STACK | ( | name | ) | LIST(name) |
Define a stack.
This macro defines a stack.
The datatype for elements must be a C struct. The struct's first member must be a pointer called next. This is used internally by the library to maintain data structure integrity and must not be modified directly by application code.
name | The name of the stack. |
|
inlinestatic |
Initialise a stack.
stack | The stack |
Definition at line 88 of file stack.h.
References list_init().
|
inlinestatic |
|
inlinestatic |
Returns the top element of the stack, without popping it.
stack | The stack |
Definition at line 123 of file stack.h.
References list_head().
|
inlinestatic |
Removes the top element from the stack.
stack | The stack |
If this function returns NULL if the stack was empty (stack underflow)
Definition at line 112 of file stack.h.
References list_pop().
|
inlinestatic |
Adds an element to the top of the stack.
stack | The stack |
element | A pointer to the element to be added |
Definition at line 99 of file stack.h.
References list_push().