00001 /* stack data structure. not thread safe. */ 00002 00003 #ifndef NPS_STACK_H 00004 #define NPS_STACK_H 00005 00006 #include <stdlib.h> 00007 #if !defined BUILDING_NPS_STACK && !defined NPS_SMALL 00008 # define NPS_STACK_LKG static inline 00009 #else 00010 # define NPS_STACK_LKG 00011 #endif 00012 00013 #include "../error/error.h" 00014 00015 typedef struct { 00016 size_t alloc_size; 00017 size_t el_size; 00018 size_t size; 00019 char *buffer; 00020 } nps_stack_t; 00021 00022 00023 NPS_STACK_LKG nps_stack_t *nps_stack_new(size_t size,size_t el_size); 00024 NPS_STACK_LKG void nps_stack_del(nps_stack_t *stack); 00025 NPS_STACK_LKG int nps_stack_push(nps_stack_t *stack, char *element, nps_error_t *error); 00026 NPS_STACK_LKG void nps_stack_pop(nps_stack_t *stack, char *out); 00027 NPS_STACK_LKG unsigned long nps_stack_size(nps_stack_t *stack); 00028 00029 00030 #endif