Hi--
I'm having trouble defining a method that is supposed to return a pointer to a struct:
Code:
count_table_t* table_allocate(int size)
{
count_table_t *test;
test=malloc(sizeof(list_node_t)*size);
return test;
}
where count_table_t and list_node_t are defined in the header file as:
Code:
typedef struct list_node list_node_t;
struct list_node {
char *key;
int value;
list_node_t *next;
};
typedef struct count_table count_table_t;
struct count_table {
int size;
//an array of list_node pointers
list_node_t **list_array;
};
I get a seg fault when running the method. Ideas? Essentially what I'm trying to do is make a count_table object with size: (size*list_node), and then return it.