I have a pointer to a pointer to a structure and I am trying to access a pointer-to-pointer pointer within that structure. I keep getting an error that reads: "request for member 'buckets' in something not a structure or union." I commented next to the error. So my question is, how do I properly access buckets and allocate memory for it.
typedef struct bucket {
char *key;
void *value;
struct bucket *next;
} Bucket;
typedef struct {
int key_count;
int table_size;
void (*free_value)(void *);
Bucket **buckets;
}
int create_table(Table ** table, int table_size, void (*free_value)(void *)){
int iterate = 0;
*table = malloc(sizeof(Table));
if(table && table_size != 0) {
(*table)->key_count = 0;
(*table)->table_size = table_size;
(*table)->free_value = free_value;
(*table)->buckets = malloc(table_size * sizeof(Bucket)); /* Error is here */
while(iterate < table_size)
*table->buckets[iterate++] = NULL;
return SUCC;
}
return FAIL;
}