On 20.02.2012 21:03, Christof Mroz wrote:
struct hip_ll_node **storage = &linkedlist->head; struct hip_ll_node *node = linkedlist->head; while(node) { if(node->ptr == ptr) { *storage = node->next; free(node); node = *storage; linkedlist->elementcount -= 1; // could return here for micro optimization } else { storage = &node->next; node = node->next; } }
Just realized this can be compacted some more: struct hip_ll_node **storage = &linkedlist->head; while(*storage) { struct hip_ll_node *const node = *storage; if(node->ptr == ptr) { linkedlist->elementcount -= 1; *storage = node->next; free(node); // could return here for micro optimization } else { storage = &node->next; } }