diff options
Diffstat (limited to '8.8/main.c')
-rw-r--r-- | 8.8/main.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/8.8/main.c b/8.8/main.c new file mode 100644 index 0000000..f4ef71e --- /dev/null +++ b/8.8/main.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include "malloc.h" + +int main(void) +{ + char *s; + + /* size of header is 16 bytes so the mem space should + * be atleast 16 * 2 = 32 bytes to call bfree */ + s = malloc(32); + bfree(s, 32); + s = my_malloc(11); + + strcpy(s, "just werks"); + printf("%s\n", s); + + /* ||-16:HEADER-||||-16:FREE-|| */ + my_free(s); + free(s - 16); + + return 0; +} |