W
wanwan
if I have the following structure and do the following procedure, will
I properly free up all allocated memory of the struture at the end?
typedef struct {
double name;
double *point2sumthing1;
double *point2sumthing2;
} obj_t;
obj_t *obj1 = (obj_t*)malloc(sizeof(obj_t));
obj1->point2sumthing1 = (double*)malloc(5*sizeof(double));
obj2->point2sumthing2 = (double*)malloc(10*sizeof(double));
....(do some stuff)
....
free(obj1);
My concern is the two double pointers. I am not certain whether free()
treats them as part of the structure
Thanks
I properly free up all allocated memory of the struture at the end?
typedef struct {
double name;
double *point2sumthing1;
double *point2sumthing2;
} obj_t;
obj_t *obj1 = (obj_t*)malloc(sizeof(obj_t));
obj1->point2sumthing1 = (double*)malloc(5*sizeof(double));
obj2->point2sumthing2 = (double*)malloc(10*sizeof(double));
....(do some stuff)
....
free(obj1);
My concern is the two double pointers. I am not certain whether free()
treats them as part of the structure
Thanks