Lines Matching refs:sp
53 stk_t *sp; in stack_new() local
55 sp = xmalloc(sizeof (stk_t)); in stack_new()
56 sp->st_nument = STACK_SEEDSIZE; in stack_new()
57 sp->st_top = -1; in stack_new()
58 sp->st_data = xmalloc(sizeof (void *) * sp->st_nument); in stack_new()
59 sp->st_free = freep; in stack_new()
61 return (sp); in stack_new()
65 stack_free(stk_t *sp) in stack_free() argument
69 if (sp->st_free) { in stack_free()
70 for (i = 0; i <= sp->st_top; i++) in stack_free()
71 sp->st_free(sp->st_data[i]); in stack_free()
73 free(sp->st_data); in stack_free()
74 free(sp); in stack_free()
78 stack_pop(stk_t *sp) in stack_pop() argument
80 assert(sp->st_top >= 0); in stack_pop()
82 return (sp->st_data[sp->st_top--]); in stack_pop()
86 stack_peek(stk_t *sp) in stack_peek() argument
88 if (sp->st_top == -1) in stack_peek()
91 return (sp->st_data[sp->st_top]); in stack_peek()
95 stack_push(stk_t *sp, void *data) in stack_push() argument
97 sp->st_top++; in stack_push()
99 if (sp->st_top == sp->st_nument) { in stack_push()
100 sp->st_nument += STACK_SEEDSIZE; in stack_push()
101 sp->st_data = xrealloc(sp->st_data, in stack_push()
102 sizeof (void *) * sp->st_nument); in stack_push()
105 sp->st_data[sp->st_top] = data; in stack_push()
109 stack_level(stk_t *sp) in stack_level() argument
111 return (sp->st_top + 1); in stack_level()