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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!