Sun, 07 Feb 2021 21:14:39 +0100
use C99 flexible array to mark the node's payload
src/linked_list.c | file | annotate | diff | comparison | revisions |
--- a/src/linked_list.c Sun Feb 07 21:03:30 2021 +0100 +++ b/src/linked_list.c Sun Feb 07 21:14:39 2021 +0100 @@ -82,7 +82,7 @@ struct cx_linked_list_node { void *prev; void *next; - int payload; + char payload[]; }; typedef struct { @@ -95,7 +95,7 @@ CxAllocator allocator = list->allocator; struct cx_linked_list_node *node = cxMalloc(allocator, - sizeof(struct cx_linked_list_node) - sizeof(int) + list->itemsize); + sizeof(struct cx_linked_list_node) + list->itemsize); if (node == NULL) return 1;