src/linked_list.c

changeset 925
fd6e191f3268
parent 919
75da57d4634e
equal deleted inserted replaced
924:3c90dfc35f06 925:fd6e191f3268
774 cx_linked_list_node *n = node; 774 cx_linked_list_node *n = node;
775 cx_for_n(i, removed) { 775 cx_for_n(i, removed) {
776 // element destruction 776 // element destruction
777 cx_invoke_destructor(list, n->payload); 777 cx_invoke_destructor(list, n->payload);
778 778
779 // free the node 779 // free the node and advance
780 void *next = n->next;
780 cxFree(list->collection.allocator, n); 781 cxFree(list->collection.allocator, n);
781 782 n = next;
782 // next
783 n = n->next;
784 } 783 }
785 } else { 784 } else {
786 char *dest = targetbuf; 785 char *dest = targetbuf;
787 cx_linked_list_node *n = node; 786 cx_linked_list_node *n = node;
788 cx_for_n(i, removed) { 787 cx_for_n(i, removed) {
790 memcpy(dest, n->payload, list->collection.elem_size); 789 memcpy(dest, n->payload, list->collection.elem_size);
791 790
792 // advance target buffer 791 // advance target buffer
793 dest += list->collection.elem_size; 792 dest += list->collection.elem_size;
794 793
795 // free the node 794 // free the node and advance
795 void *next = n->next;
796 cxFree(list->collection.allocator, n); 796 cxFree(list->collection.allocator, n);
797 797 n = next;
798 // next
799 n = n->next;
800 } 798 }
801 } 799 }
802 800
803 return removed; 801 return removed;
804 } 802 }

mercurial