From 746ea2a4ed3d395a7460ce627c64a2e1a222bc7e Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 20 May 2023 20:23:20 +0530 Subject: 8.8: initial commit --- 8.8/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 8.8/main.c (limited to '8.8/main.c') 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 +#include +#include +#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; +} -- cgit v1.2.3