Skip to content

Instantly share code, notes, and snippets.

@stefafafan
Created October 12, 2013 03:58
Show Gist options
  • Save stefafafan/6945651 to your computer and use it in GitHub Desktop.
Save stefafafan/6945651 to your computer and use it in GitHub Desktop.
free implementation
void free(void *p)
{
int size;
char *a;
a = (void *)p;
// Cannot free a NULL pointer.
if(p == NULL)
return;
// If checksum is indeed 0.
if (*(a - 4) == 0 && (a - 8) != NULL && (a - 20) != NULL)
{
size = *(a - 8);
*(a- 20) = size + 8; // Size + 8 byte headers available to use again.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment