Skip to content

Commit

Permalink
gamp
Browse files Browse the repository at this point in the history
  • Loading branch information
mirsella committed Sep 16, 2023
1 parent aa1918f commit 1369487
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/show_alloc_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
21 changes: 5 additions & 16 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 1369487

Please sign in to comment.