solved leaks still reachable because gnl wasn't going to the end, and close fd

This commit is contained in:
Hugo LAMY
2022-05-04 22:00:36 +02:00
parent d4e5f298fa
commit c89c107e09
9 changed files with 47 additions and 48 deletions

View File

@@ -6,7 +6,7 @@
/* By: pblagoje <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/04 13:56:30 by pblagoje #+# #+# */
/* Updated: 2022/05/04 13:58:58 by pblagoje ### ########.fr */
/* Updated: 2022/05/04 19:47:54 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -30,9 +30,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", EXIT_FAILURE);
mb_exit(B_RED"mb: 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", EXIT_FAILURE);
mb_exit(B_RED"mb: failed add new elmnt to list"RESET"\n", EXIT_FAILURE);
return (tmp);
}
@@ -42,7 +42,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", EXIT_FAILURE);
mb_exit(B_RED"mb: failed add new elmnt to list"RESET"\n", EXIT_FAILURE);
}
void mb_free(void *addr)
@@ -53,7 +53,7 @@ void mb_free(void *addr)
lst = mb_get_lst();
tmp = ft_lstfind((*lst), addr, mb_comp_addr);
if (!tmp)
ft_putstr_fd(B_RED"you try to free not allocated address"RESET"\n", 2);
ft_putstr_fd(B_RED"mb: try to free not allocated address"RESET"\n", 2);
ft_lsterase(tmp, free);
}