00001 #ifdef __cplusplus 00002 extern "C" { 00003 #endif 00004 00005 #ifndef CDSA_STACK_H 00006 #define CDSA_STACK_H 00007 00008 #include <stdlib.h> 00009 #include <stdbool.h> 00010 #include <string.h> 00011 #include <assert.h> 00012 00013 #include "cdsa_types.h" 00014 00051 typedef struct Stack Stack; 00052 struct Stack; 00053 00060 #define DEFAULT_STACK_CAPACITY 16 00061 00095 cdsa_status_t stack_new(Stack **new_stack, size_t elem_size, size_t capacity, 00096 cdsa_destroy_func1_t destroy); 00097 00115 cdsa_status_t stack_destroy(Stack **stack); 00116 00130 cdsa_status_t stack_push(Stack *const stack, void *const data); 00131 00152 cdsa_status_t stack_pop(Stack *const stack, void *ptr); 00153 00168 cdsa_status_t stack_peek(Stack *const stack, void *ptr); 00169 00183 cdsa_status_t stack_is_empty(const Stack *const stack, bool *is_empty); 00184 00197 cdsa_status_t stack_size(const Stack *const stack, size_t *size); 00198 00213 cdsa_status_t stack_capacity(const Stack *const stack, size_t *capacity); 00214 00215 00216 #ifdef __cplusplus 00217 } 00218 #endif 00219 00220 #endif 00221
1.5.7.1