Having a struct defined in a such way, I need to allocate memory
typedef struct string_collection {
char **c;
size_t current, allocated;
} TSC, *ASC;
So I came with this code, is it right or I missed something? First allocating struct descriptor and then enough space for d pointers to string
ASC AlocSC(size_t d)
{
ASC sc;
sc = (TSC*) malloc(sizeof(TSC));
if (!sc) return NULL;
sc->c = calloc(d, sizeof(char *));
if (!sc->c) {
free(sc);
return NULL;
}
sc->current = 0;
sc->allocated = d;
return sc;
}