Thus, in most implementations, malloc stores a header in front of the allocated memory to track the allocated memory (so that it can do free and rememberoc). What is the content of the header?
I wrote naive code to find it, but that makes no sense
int * ptr;
ptr = malloc(12*sizeof(int));
printf("Header = %d\n",*(ptr-1));
He returns
Header = 57
What's going on here?
Bruce source
share