Lines Matching refs:pstack
15 struct pstack { struct
21 struct pstack *pstack__new(unsigned short max_nr_entries) in pstack__new() argument
23 struct pstack *pstack = zalloc((sizeof(*pstack) + in pstack__new() local
25 if (pstack != NULL) in pstack__new()
26 pstack->max_nr_entries = max_nr_entries; in pstack__new()
27 return pstack; in pstack__new()
30 void pstack__delete(struct pstack *pstack) in pstack__delete() argument
32 free(pstack); in pstack__delete()
35 bool pstack__empty(const struct pstack *pstack) in pstack__empty() argument
37 return pstack->top == 0; in pstack__empty()
40 void pstack__remove(struct pstack *pstack, void *key) in pstack__remove() argument
42 unsigned short i = pstack->top, last_index = pstack->top - 1; in pstack__remove()
45 if (pstack->entries[i] == key) { in pstack__remove()
47 memmove(pstack->entries + i, in pstack__remove()
48 pstack->entries + i + 1, in pstack__remove()
50 --pstack->top; in pstack__remove()
57 void pstack__push(struct pstack *pstack, void *key) in pstack__push() argument
59 if (pstack->top == pstack->max_nr_entries) { in pstack__push()
60 pr_err("%s: top=%d, overflow!\n", __func__, pstack->top); in pstack__push()
63 pstack->entries[pstack->top++] = key; in pstack__push()
66 void *pstack__pop(struct pstack *pstack) in pstack__pop() argument
70 if (pstack->top == 0) { in pstack__pop()
75 ret = pstack->entries[--pstack->top]; in pstack__pop()
76 pstack->entries[pstack->top] = NULL; in pstack__pop()
80 void *pstack__peek(struct pstack *pstack) in pstack__peek() argument
82 if (pstack->top == 0) in pstack__peek()
84 return pstack->entries[pstack->top - 1]; in pstack__peek()