Information about the current block of memory:
typedef struct {
struct metadata *next;
size_t size;
} metadata;
int main(void)
{
metadata* md = malloc(sizeof(metadata) + 64);
printf("metadata address:\t%p\n", md);
printf("start of allocation:\t%p\n", md + 1);
free(md);
return 0;
}
$ gcc malloc-main.c -o malloc-main
$ ./malloc-main
metadata address: 0x563eaaa8f2a0
start of allocation: 0x563eaaa8f2b0
meta_data * head
: head for linked-listtotal_memory_requested
: keep track of bytes usedtotal_memory_freed
: keep track of bytes freedinvalid_addresses
char*
Understanding how to do this will be useful when you implement malloc!