fix norm and set chunk sizes
This commit is contained in:
@ -6,18 +6,18 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/11/30 12:19:34 by tomoron #+# #+# */
|
||||
/* Updated: 2024/12/02 15:24:45 by tomoron ### ########.fr */
|
||||
/* Updated: 2024/12/03 18:50:25 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "includes/malloc.h"
|
||||
|
||||
void put_ulnbr_base(t_ul nbr, char *base)
|
||||
static void put_ulnbr_base(t_ul nbr, char *base)
|
||||
{
|
||||
t_ul base_len;
|
||||
t_ul base_len;
|
||||
|
||||
base_len = ft_strlen(base);
|
||||
if(nbr >= base_len)
|
||||
if (nbr >= base_len)
|
||||
{
|
||||
put_ulnbr_base(nbr / base_len, base);
|
||||
write(1, base + (nbr % base_len), 1);
|
||||
@ -26,32 +26,33 @@ void put_ulnbr_base(t_ul nbr, char *base)
|
||||
write(1, base + nbr, 1);
|
||||
}
|
||||
|
||||
size_t show_allocs(t_alloc *alloc)
|
||||
static size_t show_allocs(t_alloc *alloc)
|
||||
{
|
||||
size_t nb_bytes;
|
||||
|
||||
size_t nb_bytes;
|
||||
|
||||
nb_bytes = 0;
|
||||
while(alloc)
|
||||
while (alloc)
|
||||
{
|
||||
nb_bytes += alloc->size;
|
||||
write(1, "0x", 2);
|
||||
put_ulnbr_base((t_ul)alloc + sizeof(t_alloc), "0123456789ABCDEF");
|
||||
write(1, " - 0x", 5);
|
||||
put_ulnbr_base((t_ul)alloc +sizeof(t_alloc) + alloc->size, "0123456789ABCDEF");
|
||||
put_ulnbr_base((t_ul)alloc + sizeof(t_alloc) + alloc->size, \
|
||||
"0123456789ABCDEF");
|
||||
write(1, " : ", 3);
|
||||
put_ulnbr_base(alloc->size, "0123456789");
|
||||
write(1, " bytes\n", 7);
|
||||
alloc = alloc->next;
|
||||
}
|
||||
return(nb_bytes);
|
||||
return (nb_bytes);
|
||||
}
|
||||
|
||||
size_t show_pre_allocated(char *type, t_mem_chunk *chunk)
|
||||
static size_t show_pre_allocated(char *type, t_mem_chunk *chunk)
|
||||
{
|
||||
size_t nb_bytes;
|
||||
size_t nb_bytes;
|
||||
|
||||
nb_bytes = 0;
|
||||
while(chunk)
|
||||
while (chunk)
|
||||
{
|
||||
write(1, type, ft_strlen(type));
|
||||
write(1, " : 0x", 5);
|
||||
@ -60,21 +61,21 @@ size_t show_pre_allocated(char *type, t_mem_chunk *chunk)
|
||||
nb_bytes += show_allocs(chunk->first);
|
||||
chunk = chunk->next;
|
||||
}
|
||||
return(nb_bytes);
|
||||
return (nb_bytes);
|
||||
}
|
||||
|
||||
size_t show_large()
|
||||
static size_t show_large(void)
|
||||
{
|
||||
t_alloc *alloc;
|
||||
size_t total_size;
|
||||
t_alloc *alloc;
|
||||
size_t total_size;
|
||||
|
||||
alloc = g_allocs.large;
|
||||
total_size = 0;
|
||||
while(alloc)
|
||||
while (alloc)
|
||||
{
|
||||
write(1, "LARGE : 0x", 10);
|
||||
put_ulnbr_base((t_ul)alloc, "0123456789ABCDEF");
|
||||
write(1,"\n", 1);
|
||||
write(1, "\n", 1);
|
||||
write(1, "0x", 2);
|
||||
put_ulnbr_base((t_ul)(alloc + 1), "0123456789ABCDEF");
|
||||
write(1, " - 0x", 5);
|
||||
@ -85,12 +86,12 @@ size_t show_large()
|
||||
total_size += alloc->size;
|
||||
alloc = alloc->next;
|
||||
}
|
||||
return(total_size);
|
||||
return (total_size);
|
||||
}
|
||||
|
||||
void show_alloc_mem()
|
||||
void show_alloc_mem(void)
|
||||
{
|
||||
size_t total;
|
||||
size_t total;
|
||||
|
||||
total = 0;
|
||||
total += show_pre_allocated("TINY", g_allocs.tiny);
|
||||
|
Reference in New Issue
Block a user