Question: Write code to free the memory created in the following createBox method. struct book char * author; }; struct box { book ** collection; int

Write code to free the memory created in the following createBox method. struct book char * author; }; struct box { book ** collection; int size, cap; }; box * createBox(int amt) { box * ret = calloc(1, sizeof(box)); ret->size = amt; ret->cap = amt; for (int i = 0; i collection[i] = calloc(1, sizeof(book)); ret->collection[i]->author = calloc(20, sizeof(char)); } return ret; } void destroyBox(box * myBox) { // Your code would go here! }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
