Three Bytes Into The Chunk
char *rec = malloc(64);
memcpy(rec, "id=", 3);
memcpy(rec + 3, payload, 61);
char *val = rec + 3; /* points at the value, not the chunk */
/* ... hours later, in a different function ... */
free(val);
The allocator stores each chunk's size and flags in the 8 bytes immediately preceding the pointer it returned. What does free(val) actually do?
Sign in to answer questions and track your progress
Sign In