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