I created the following 2 structs:
typedef struct my_struct_element{
int key;
int value;
struct my_struct_element *next;
} my_struct_element;
typedef struct my_struct{
int size;
my_struct_element arr[];
} my_struct;
It's a part of a simple hashtable implementation that I am trying to accomplish. Now the problem that I have is that the size of my hashtable isn't fixed, and therefore when I call sizeof(my_struct), I don't get actually the size of my struct. Am I going down on the wrong path here, and should I use a pointer instead of my array? Like
my_struct_element* arr = malloc(sizeof(my_struct_element)*arr_size);
my_struct ms = {arr_size, arr};
But this way the my_struct instance is on the stack, not the heap, and only my array is on the heap.
Any good advice would be appreciated