From 13694875ff76fe1f4d016660651a1a697dcf4cb3 Mon Sep 17 00:00:00 2001 From: mirsella Date: Sat, 16 Sep 2023 23:35:32 +0200 Subject: [PATCH] gamp --- src/show_alloc_mem.c | 8 ++++---- test.c | 21 +++++---------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/show_alloc_mem.c b/src/show_alloc_mem.c index 526492f..d86a69d 100644 --- a/src/show_alloc_mem.c +++ b/src/show_alloc_mem.c @@ -46,10 +46,10 @@ void show_alloc_mem_ex() { continue; ft_printf("%p - %p : %d bytes\n", ALLOC_SHIFT(alloc), ALLOC_SHIFT(alloc) + alloc->size, alloc->size); - size_t size = - ft_memchr(ALLOC_SHIFT(alloc), 0, alloc->size) - ALLOC_SHIFT(alloc); - /* write(1, ALLOC_SHIFT(alloc), alloc->size); */ - ft_printf("%x\n", ALLOC_SHIFT(alloc)); + /* size_t size = */ + /* ft_memchr(ALLOC_SHIFT(alloc), 0, alloc->size) - ALLOC_SHIFT(alloc); + */ + // TODO: hexdump the alloc if (alloc->next == alloc) { ft_printf("detected infinite loop on alloc at %p\n", ALLOC_SHIFT(alloc)); diff --git a/test.c b/test.c index 4f8f88a..27801b9 100644 --- a/test.c +++ b/test.c @@ -29,22 +29,11 @@ int main(void) { /* char *c = malloc(len); */ /* ft_printf("c(%p)\n", c); */ /* ft_bzero(c, len); */ - - ft_printf("allocating 5000 times\n"); - for (int i = 1; i < 50000; i += 3) { - char *d = malloc(i); - /* d = realloc(d, i); */ - /* d = realloc(d, i - 1); */ - /* d = realloc(d, i + 1); */ - ((void)d); - ft_bzero(d, i); - bzero(d, i); - ft_memset(d, 'a', i); - memset(d, 'b', i); - free(d); - } - + /**/ ft_putchar('\n'); - show_alloc_mem(); + + char *a = malloc(10); + ft_memset(a, 'a', 10); + show_alloc_mem_ex(); return EXIT_SUCCESS; }