Message ID | 20170707134002.49500-27-luc.vanoostenryck@gmail.com (mailing list archive) |
---|---|
State | Rejected, archived |
Headers | show |
diff --git a/ptrlist.c b/ptrlist.c index 95ff319db..cdc4ae4b0 100644 --- a/ptrlist.c +++ b/ptrlist.c @@ -171,15 +171,19 @@ out: int replace_ptr_list_entry(struct ptr_list **list, void *old_ptr, void *new_ptr, int count) { - void *ptr; + struct ptr_cur cur; + + if (!ptr_cur_beg(&cur, *list)) + goto out; - FOR_EACH_PTR(*list, ptr) { - if (ptr==old_ptr) { - REPLACE_CURRENT_PTR(ptr, new_ptr); + while (ptr_cur_next(&cur)) { + void **this = &cur.l->list[cur.n]; + if (*this == old_ptr) { + *this = new_ptr; if (!--count) goto out; } - }END_FOR_EACH_PTR(ptr); + } assert(count <= 0); out: return count;