norme fix
This commit is contained in:
@ -6,14 +6,13 @@
|
|||||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/14 18:03:26 by tomoron #+# #+# */
|
/* Created: 2025/02/14 18:03:26 by tomoron #+# #+# */
|
||||||
/* Updated: 2025/02/15 16:19:00 by tomoron ### ########.fr */
|
/* Updated: 2025/02/15 16:25:42 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "includes/malloc.h"
|
#include "includes/malloc.h"
|
||||||
|
|
||||||
|
static void put_hex_padded(t_ul addr, int padding, int prefix)
|
||||||
static void put_hex_padded(t_ul addr, int padding, int prefix)
|
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
t_ul tmp;
|
t_ul tmp;
|
||||||
@ -25,9 +24,9 @@ static void put_hex_padded(t_ul addr, int padding, int prefix)
|
|||||||
tmp /= 16;
|
tmp /= 16;
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
if(prefix)
|
if (prefix)
|
||||||
write(1, "0x", 2);
|
write(1, "0x", 2);
|
||||||
while(len < padding)
|
while (len < padding)
|
||||||
{
|
{
|
||||||
write(1, "0", 1);
|
write(1, "0", 1);
|
||||||
len++;
|
len++;
|
||||||
@ -35,68 +34,67 @@ static void put_hex_padded(t_ul addr, int padding, int prefix)
|
|||||||
put_ulnbr_base(addr, "0123456789abcdef");
|
put_ulnbr_base(addr, "0123456789abcdef");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void put_char_dot(char c)
|
static void put_char_dot(char c)
|
||||||
{
|
{
|
||||||
if(c >= 32 && c <= 126)
|
if (c >= 32 && c <= 126)
|
||||||
write(1, &c, 1);
|
write(1, &c, 1);
|
||||||
else
|
else
|
||||||
write(1, ".", 1);
|
write(1, ".", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hex_dump_show_line(char *addr, int len)
|
static void hex_dump_show_line(char *addr, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
put_hex_padded((long unsigned)addr, 16, 1);
|
put_hex_padded((long unsigned)addr, 16, 1);
|
||||||
write(1, " ", 2);
|
write(1, " ", 2);
|
||||||
i = 0;
|
i = 0;
|
||||||
while(i < 16)
|
while (i < 16)
|
||||||
{
|
{
|
||||||
if(i < len)
|
if (i < len)
|
||||||
put_hex_padded(addr[i], 2, 0);
|
put_hex_padded(addr[i], 2, 0);
|
||||||
else
|
else
|
||||||
write(1, " ", 2);
|
write(1, " ", 2);
|
||||||
write(1, " ", 1);
|
write(1, " ", 1);
|
||||||
if(i == 7 || i == 15)
|
if (i == 7 || i == 15)
|
||||||
write(1, " ", 1);
|
write(1, " ", 1);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
write(1, "|", 1);
|
write(1, "|", 1);
|
||||||
while(i < len)
|
while (i < len)
|
||||||
{
|
{
|
||||||
put_char_dot(addr[i]);
|
put_char_dot(addr[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
write(1, "|", 1);
|
write(1, "|\n", 2);
|
||||||
write(1, "\n", 1);
|
|
||||||
(void)len;
|
(void)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hex_dump(char *addr, size_t nb)
|
void hex_dump(char *addr, size_t nb)
|
||||||
{
|
{
|
||||||
char buf[16];
|
char buf[16];
|
||||||
size_t cur;
|
size_t cur;
|
||||||
int lst_same;
|
int lst_same;
|
||||||
|
|
||||||
cur = 0;
|
cur = 0;
|
||||||
lst_same = 0;
|
lst_same = 0;
|
||||||
while (cur + 16 < nb)
|
while (cur + 16 < nb)
|
||||||
{
|
{
|
||||||
if(cur && !ft_memcmp(buf, addr + cur, 16))
|
if (cur && !ft_memcmp(buf, addr + cur, 16))
|
||||||
{
|
{
|
||||||
cur += 16;
|
cur += 16;
|
||||||
if(!lst_same)
|
if (!lst_same)
|
||||||
write(1, "*\n", 2);
|
write(1, "*\n", 2);
|
||||||
lst_same = 1;
|
lst_same = 1;
|
||||||
continue;
|
continue ;
|
||||||
}
|
}
|
||||||
lst_same = 0;
|
lst_same = 0;
|
||||||
ft_memcpy(buf, addr + cur, 16);
|
ft_memcpy(buf, addr + cur, 16);
|
||||||
hex_dump_show_line(addr + cur, 16);
|
hex_dump_show_line(addr + cur, 16);
|
||||||
cur += 16;
|
cur += 16;
|
||||||
}
|
}
|
||||||
if(cur < nb)
|
if (cur < nb)
|
||||||
hex_dump_show_line(addr + cur, nb - cur);
|
hex_dump_show_line(addr + cur, nb - cur);
|
||||||
put_hex_padded((long unsigned)addr, 16, 1);
|
put_hex_padded((long unsigned)addr, 16, 1);
|
||||||
write(1, "\n", 1);
|
write(1, "\n", 1);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/11/30 12:19:34 by tomoron #+# #+# */
|
/* Created: 2024/11/30 12:19:34 by tomoron #+# #+# */
|
||||||
/* Updated: 2025/02/14 18:18:48 by tomoron ### ########.fr */
|
/* Updated: 2025/02/15 16:26:09 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ static size_t show_allocs(t_alloc *alloc, int dump)
|
|||||||
write(1, " : ", 3);
|
write(1, " : ", 3);
|
||||||
put_ulnbr_base(alloc->size, "0123456789");
|
put_ulnbr_base(alloc->size, "0123456789");
|
||||||
write(1, " bytes\n", 7);
|
write(1, " bytes\n", 7);
|
||||||
if(dump)
|
if (dump)
|
||||||
hex_dump((void *)(alloc + 1), alloc->size);
|
hex_dump((void *)(alloc + 1), alloc->size);
|
||||||
alloc = alloc->next;
|
alloc = alloc->next;
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ size_t show_large(int dump)
|
|||||||
put_ulnbr_base(alloc->size, "0123456789");
|
put_ulnbr_base(alloc->size, "0123456789");
|
||||||
write(1, " bytes\n", 7);
|
write(1, " bytes\n", 7);
|
||||||
total_size += alloc->size;
|
total_size += alloc->size;
|
||||||
if(dump)
|
if (dump)
|
||||||
hex_dump((void *)(alloc + 1), alloc->size);
|
hex_dump((void *)(alloc + 1), alloc->size);
|
||||||
alloc = alloc->next;
|
alloc = alloc->next;
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/14 17:26:41 by tomoron #+# #+# */
|
/* Created: 2025/02/14 17:26:41 by tomoron #+# #+# */
|
||||||
/* Updated: 2025/02/14 17:48:53 by tomoron ### ########.fr */
|
/* Updated: 2025/02/15 16:23:04 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "includes/malloc.h"
|
#include "includes/malloc.h"
|
||||||
|
|
||||||
void show_alloc_mem_ex(void)
|
void show_alloc_mem_ex(void)
|
||||||
{
|
{
|
||||||
size_t total;
|
size_t total;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user