putnbr_hex instead of putaddr

This commit is contained in:
Jack Halford 2017-02-19 21:22:03 +01:00
parent c395e96cd5
commit 0f94380f7c
7 changed files with 9 additions and 9 deletions

@ -1 +1 @@
Subproject commit 0ca8ca817f32fc0345ef93ef74a3abe2583bd89c Subproject commit 5e978382fff27082681383029d99f76ae5a25ddc

Binary file not shown.

View file

@ -22,7 +22,7 @@ void error_free_notalloc(void *ptr)
ft_putstr_fd(", ??? ", fd); ft_putstr_fd(", ??? ", fd);
ft_putstr_fd(")", fd); ft_putstr_fd(")", fd);
ft_putstr_fd(" malloc: error for object ", fd); ft_putstr_fd(" malloc: error for object ", fd);
ft_putaddr_fd(ptr, fd); ft_putnbr_hex_fd((long)ptr, fd);
ft_putendl_fd(": pointer being freed was not allocated"FG_DEFAULT, fd); ft_putendl_fd(": pointer being freed was not allocated"FG_DEFAULT, fd);
/* exit(134); */ /* exit(134); */
} }

View file

@ -41,12 +41,14 @@ void free(void *ptr)
t_node *node; t_node *node;
ft_putstr(FG_YELLOW"free("); ft_putstr(FG_YELLOW"free(");
ft_putaddr(ptr); ft_putnbr_hex((long)ptr);
ft_putendl(")"FG_DEFAULT); ft_putendl(")"FG_DEFAULT);
if (!ptr) if (!ptr)
return ; return ;
node = ptr - HEADER_SIZE; node = ptr - HEADER_SIZE;
get_zones(&zone_ref, &alloc_ref, node->size); get_zones(&zone_ref, &alloc_ref, node->size);
ft_putstr("zone @");
*zone_ref ? print_node(BG_MAGENTA, *zone_ref) : ft_putendl(" NULL");
if (remove_node(alloc_ref, node)) if (remove_node(alloc_ref, node))
{ {
error_free_notalloc(ptr); error_free_notalloc(ptr);

View file

@ -31,6 +31,4 @@ void get_zones(t_node ***zone_ref, t_node ***alloc_ref, size_t size)
*zone_ref = TINY(size) ? &tiny_zone : &small_zone; *zone_ref = TINY(size) ? &tiny_zone : &small_zone;
*alloc_ref = TINY(size) ? &tiny_alloc : &small_alloc; *alloc_ref = TINY(size) ? &tiny_alloc : &small_alloc;
} }
ft_putstr("zone @");
**zone_ref ? print_node(BG_MAGENTA, **zone_ref) : ft_putendl(" NULL");
} }

View file

@ -56,9 +56,9 @@ int remove_node(t_node **head, t_node *node)
while (*head) while (*head)
{ {
ft_putstr("looking for node; diff=["); ft_putstr("looking for node; diff=[");
ft_putaddr(node); ft_putnbr_hex((long)node);
ft_putstr(","); ft_putstr(",");
ft_putaddr(*head); ft_putnbr_hex((long)*head);
ft_putendl("]"); ft_putendl("]");
if (*head == node) if (*head == node)
{ {

View file

@ -23,9 +23,9 @@ void print_node(char color[7], t_node *node)
{ {
ft_putstr("\t"); ft_putstr("\t");
ft_putstr(color); ft_putstr(color);
ft_putaddr(node->data); ft_putnbr_hex((long)node->data);
ft_putstr(" - "); ft_putstr(" - ");
ft_putaddr(node->data + node->size); ft_putnbr_hex((long)node->data + node->size);
ft_putstr(FBG_DEFAULT" : "); ft_putstr(FBG_DEFAULT" : ");
ft_putnbr(node->size); ft_putnbr(node->size);
ft_putendl(" bytes"); ft_putendl(" bytes");