pelib  2.0.0
include/pelib/stack.c File Reference
#include <assert.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
Include dependency graph for stack.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int pelib_init (stackelem_t(STACK_T))
int pelib_stackelem_write() STACK_T (stackelem_t(STACK_T)*elem, STACK_T buffer)
int pelib_stackelem_read() STACK_T (stackelem_t(STACK_T)*elem, STACK_T *buffer)
int pelib_stackelem_check() STACK_T (stackelem_t(STACK_T)*elem)
 stack_t (STACK_T)
int pelib_init (stack_t(STACK_T))
int pelib_free (stack_t(STACK_T))
int pelib_stack_check() STACK_T (stack_t(STACK_T)*s)
int pelib_stack_push() STACK_T (stack_t(STACK_T)*s, STACK_T buffer)
int pelib_stack_pop() STACK_T (stack_t(STACK_T)*s, STACK_T *buffer)
int pelib_stack_push_elem() STACK_T (stack_t(STACK_T)*s, stackelem_t(STACK_T)*elem)
int pelib_stack_pop_elem() STACK_T (stack_t(STACK_T)*s, stackelem_t(STACK_T)**elem)
int pelib_stack_push_safe_managed() STACK_T (stack_t(STACK_T)*s, stack_t(STACK_T)*pool, STACK_T buffer)
int pelib_stack_pop_safe_managed() STACK_T (stack_t(STACK_T)*s, stack_t(STACK_T)*pool, STACK_T *buffer)

Function Documentation

Definition at line 96 of file stack.c.

Definition at line 32 of file stack.c.

Definition at line 82 of file stack.c.

Writes data into an existing stack element

Definition at line 41 of file stack.c.

Reads data from a stack element

Definition at line 49 of file stack.c.

Checks if a stack element is valid

Definition at line 58 of file stack.c.

Definition at line 65 of file stack.c.

Returns 0 if the stack is not in a consistent state

Returns 0 is the stack holds at least one element

Definition at line 105 of file stack.c.

int pelib_stack_push() STACK_T ( stack_t(STACK_T)*  stack,
STACK_T  data 
)

Allocates a new stack element, write the element in it and push it to the stack

Pushes an element to the stack in a thread-safe manner

Definition at line 119 of file stack.c.

Read value from the head stack element, removes the head stack element and free the stack element

Read the head value from the stack but doesn't remove the head element

Pops an element to the stack in a thread-safe manner

Definition at line 137 of file stack.c.

Pushes an existing stack element to the stack

Push a stack element in a thread-safe manner

Definition at line 186 of file stack.c.

Pops the head element of the stack without reading its value or freeing it

Pops a stack element in thread-safe manner

Definition at line 199 of file stack.c.

Pushes a new value in the stack, reusing a stack element from a stack element recycling bin. Allocates a new element if the recycle bin is empty

Parameters:
stackStack that receives the new element
binRecycle bin (stack) that contains stack element to be reused
valueValue to be pushed in the stack
Returns:
0 If the push operation could not be performed

Definition at line 240 of file stack.c.

Pops the head value of a stack, saves the stack element popped in a recycling bin and writes the value read in ptr

Parameters:
stackStack toread head element from
binStack element recycle bin
ptrMemory address where the value popped is written

Definition at line 260 of file stack.c.