Given the following structure university_t:
typedef struct university { char* city; int creation; person_t* rector; } university_t;
And the structure person_t:
typedef struct person { char* name; int salary; int age; } person_t;
You are asked to implement the functions init_all
and free_all
, which respectively initialises the structure university_t and frees all the memory associated with it.
The name and the city have been allocated with malloc.
Hint: all the data may not have been initialised correctly. Therefore, you have to handle all the cases (e.g. some pointers can be already NULL, and don't need to be freed).