I\'m not sure exactly what I need to use as an argument to malloc
to allocate space in the table_allocate(int)
function. I was thinking just
Your suggestion: count_table* cTable = malloc(sizeof(count_table*))
would only allocate space for a pointer to a count_table.
You'd need
count_table* cTable = malloc(sizeof(count_table) ) ;
Each list node would be separately allocated and cTable->size and cTable->list_array and the last list_node_t::next
updated accordingly. Maintaining a pointer to the last node added would make adding nodes faster.
I am not sure why count_table::list_array
is of type list_node_t**
rather than just list_node_t*
(and equally called list_array
rather than just list
). Is it your intention that it is both an array and a list at the same time? That would be somewhat redundant. The member need only be a pointer to the first node, successive nodes are then accessed via list_node::next