I need your help with syntax and maybe logic.
My struct looks like this
Code:
struct Domains {
u_int count;
struct Domain *dptr[];
};
I want the *dptr[] to be an array holding pointers to struct Domain. That way in my program as I see a new domain I can dynamically add an element to the array *dptr[]. The element will simply be a struct pointer pointing to a Domain struct.
So I am thinking that I would do a malloc for the struct pointer to increase the *dptr[] array by 1 and another malloc for the actual Domain struct. Is that correct?
My pseudo ish code so far.
Code:
Domain *domain = calloc(1, sizeof(struct Domain *)); // allocate memory for struct pointer
init->Dptr->dptr[count] = &domain; // How do I put that pointer into init->Dtpr->dtpr[count]?
Domain *domain = calloc(1, sizeof(struct Domain)); // allocate memory for an actual Domain struct
init->Dptr->dptr[count] = domain; // I think this part is correct
Here is the Domain struct.
Code:
struct Domain {
u_int GET, POST;
u_int num_requests;
u_int total_requests;
char name[32];
struct Request *requests[];
};
The same would apply to the *requests[] array in the Domain struct.