changed rgb deal, and improve memorybook with 2d

This commit is contained in:
hugogogo
2022-05-01 22:55:00 +02:00
parent 43852938c4
commit eb5f2db7fa
9 changed files with 60 additions and 54 deletions

View File

@@ -18,9 +18,9 @@ void *mb_alloc(size_t size)
lst = mb_get_lst();
tmp = ft_memalloc(size);
if (!tmp)
mb_exit(B_RED"failed create new allocation"RESET"\n");
mb_exit(B_RED"failed create new allocation"RESET"\n", EXIT_FAILURE);
if (!ft_lstpush_back(lst, ft_lstcreate(tmp)))
mb_exit(B_RED"failed add new element to list"RESET"\n");
mb_exit(B_RED"failed add new element to list"RESET"\n", EXIT_FAILURE);
return (tmp);
}
@@ -30,7 +30,7 @@ void mb_add(void *addr)
lst = mb_get_lst();
if (!ft_lstpush_back(lst, ft_lstcreate(addr)))
mb_exit(B_RED"failed add new element to list"RESET"\n");
mb_exit(B_RED"failed add new element to list"RESET"\n", EXIT_FAILURE);
}
void mb_free(void *addr)
@@ -45,7 +45,7 @@ void mb_free(void *addr)
ft_lsterase(tmp, free);
}
void mb_exit(char *str)
void mb_exit(char *str, int status)
{
t_list **lst;
@@ -53,5 +53,5 @@ void mb_exit(char *str)
mb_exec_exit_func();
ft_putstr_fd(str, 2);
ft_lstfree((*lst), free);
exit(0);
exit(status);
}

19
srcs/mem/memorybook_2d.c Normal file
View File

@@ -0,0 +1,19 @@
#include "cube3d.h"
void mb_add_2d(void **addr, int nb)
{
while (nb)
{
mb_add(addr[nb]);
nb--;
}
}
void mb_free_2d(void **addr, int nb)
{
while (nb)
{
mb_free(addr[nb]);
nb--;
}
}