Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

stack.h File Reference

Go to the source code of this file.

Defines

#define stack_init   list_init
 Initialize the stack. The prototype for this function is the same than for list_init(). Please consult the documentation for the linked list API.

#define stack_destroy   list_destroy
 Free all memory allocated for the stack. The prototype for this function is the same than for list_destroy(). Please consult the documentation for the linked list API.

#define stack_peek(pile)   ((pile)->tete == NULL ? NULL : (pile)->tete->donnee)
 Return a pointer to the element at the top of the list (the element is NOT extracted from the list).

#define stack_size   list_size
 Return the numder of element in the stack. This macro is identical to the macro list_size used for linked list. Please consult the documentation for the linked list API.


Typedefs

typedef List Stack
 A stack is implemented as a linked list.


Functions

int stack_push (Stack *pile, const void *donnee)
 Stack up data at the top of the stack.

int stack_pop (Stack *pile, void **donnee)
 Extract data from the top of the stack.


Detailed Description

Header file for stack.c

Definition in file stack.h.


Define Documentation

#define stack_peek pile       ((pile)->tete == NULL ? NULL : (pile)->tete->donnee)
 

Return a pointer to the element at the top of the list (the element is NOT extracted from the list).

Parameters:
Pointer to a stack data structure.
Examples:
test_stack.c.

Definition at line 42 of file stack.h.


Function Documentation

int stack_pop Stack   pile,
void **    donnee
 

Extract data from the top of the stack.

Parameters:
pile Pointer to a stack data structure.
donnee Pointer to a pointer the will point to the extracted data.
Returns:
Upon successful completion the function return the value 0. Otherwise the function returns -1.
Warning:
This function does NOT free the element's data (it only frees the element's structure). Therefore you should use donnee to free the element's data yourself.

Definition at line 33 of file stack.c.

References list_rem_next().

int stack_push Stack   pile,
const void *    donnee
 

Stack up data at the top of the stack.

Parameters:
pile Pointer to a stack data structure.
donnee Pointer to the data to stack up.
Returns:
Upon successful completion the function return the value 0. Otherwise the function returns -1.
Warning:
The inserted data is NOT copied into the linked list! Therefore you should not free it unless you know exactly what you are doing.

Definition at line 19 of file stack.c.

References list_ins_next().


Generated on Thu Apr 3 16:23:47 2003 for Common_C_libraries by doxygen1.3-rc1