My question is regarding C, specifically the gcc compiler.
Essentially, I did the following:
Did I free the memory properly?Code:void *ptr = malloc( (sizeof(int)*2) + (sizeof(char)*STRLEN) );
void *p = ptr;
*(int*)p = 1;
p += sizeof(int);
*(int*)p = 2;
p += sizeof(int);
strcpy((char*)p, "hello");
// did some stuff
free( ptr );
I know the first integer is freed, but I accidentily printed the values of all these locations and the second integer's and string's values were still intact.
