On Thu, 15 Mar 2007 01:19:04 +0900, Sylvain Joyeux <sylvain.joyeux / m4x.org> wrote:
> Yup. Here is the right one.
Hmm, why not just add a "prev" variable?
static void
remove_one(List *list, VALUE value)
{
Entry **ref;
Entry *entry;
Entry *prev;
for (ref = &list->entries, prev = NULL, entry = list->entries;
entry != NULL;
ref = &entry->next, prev = entry, entry = entry->next) {
if (entry->value == value) {
*ref = entry->next;
--list->size;
if (!entry->next) {
list->last_entry = prev;
}
recycle_entries(list, entry, entry);
break;
}
}
}
-mental