-
-
Save stefafafan/6945651 to your computer and use it in GitHub Desktop.
free implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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