diff options
author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-08-11 15:12:04 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-08-11 15:12:04 -0700 |
commit | f39e2bb1cd833b37a6ac98d2521e92b87e1c315c (patch) | |
tree | 46aa3388694b42d476f979d5832262e83e6627b3 /ptrlist.c | |
parent | Have more bits for "stream number" in "struct pos" (diff) | |
download | sparse-f39e2bb1cd833b37a6ac98d2521e92b87e1c315c.tar.gz sparse-f39e2bb1cd833b37a6ac98d2521e92b87e1c315c.tar.bz2 sparse-f39e2bb1cd833b37a6ac98d2521e92b87e1c315c.zip |
Add 'undo_ptr_list_last()' helper function
It's like 'delete_ptr_list_last()', except it doesn't de-allocate the
ptrlist block that it removes the last entry from. Useful when you know
you're going to add things back (ie basic block tail rewriting), and
when you can't afford to de-allocate the ptrlist because you're in a
loop.
Diffstat (limited to 'ptrlist.c')
-rw-r--r-- | ptrlist.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -177,6 +177,27 @@ out: return count; } +/* This removes the last entry, but doesn't pack the ptr list */ +void * undo_ptr_list_last(struct ptr_list **head) +{ + struct ptr_list *last, *first = *head; + + if (!first) + return NULL; + last = first; + do { + last = last->prev; + if (last->nr) { + void *ptr; + int nr = --last->nr; + ptr = last->list[nr]; + last->list[nr] = (void *)0xf1f1f1f1; + return ptr; + } + } while (last != first); + return NULL; +} + void * delete_ptr_list_last(struct ptr_list **head) { void *ptr = NULL; |