Home | History | Annotate | Download | only in util

Lines Matching refs:pstack

8 #include "pstack.h"
12 struct pstack {
18 struct pstack *pstack__new(unsigned short max_nr_entries)
20 struct pstack *pstack = zalloc((sizeof(*pstack) +
22 if (pstack != NULL)
23 pstack->max_nr_entries = max_nr_entries;
24 return pstack;
27 void pstack__delete(struct pstack *pstack)
29 free(pstack);
32 bool pstack__empty(const struct pstack *pstack)
34 return pstack->top == 0;
37 void pstack__remove(struct pstack *pstack, void *key)
39 unsigned short i = pstack->top, last_index = pstack->top - 1;
42 if (pstack->entries[i] == key) {
44 memmove(pstack->entries + i,
45 pstack->entries + i + 1,
47 --pstack->top;
51 pr_err("%s: %p not on the pstack!\n", __func__, key);
54 void pstack__push(struct pstack *pstack, void *key)
56 if (pstack->top == pstack->max_nr_entries) {
57 pr_err("%s: top=%d, overflow!\n", __func__, pstack->top);
60 pstack->entries[pstack->top++] = key;
63 void *pstack__pop(struct pstack *pstack)
67 if (pstack->top == 0) {
72 ret = pstack->entries[--pstack->top];
73 pstack->entries[pstack->top] = NULL;