diff --git a/srcs/free.c b/srcs/free.c index 7512f60..e12aa29 100644 --- a/srcs/free.c +++ b/srcs/free.c @@ -6,18 +6,13 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/30 18:46:07 by tomoron #+# #+# */ -/* Updated: 2024/12/04 18:23:00 by tomoron ### ########.fr */ +/* Updated: 2024/12/04 18:52:39 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include "includes/malloc.h" -void invalid_pointer(char *fnc) -{ - (void)fnc; - write(2, fnc, ft_strlen(fnc)); - write(2, "(): invalid pointer\n", 21); -} +void invalid_pointer(char *fnc); t_mem_chunk *get_alloc_chunk(t_alloc *alloc, t_mem_chunk *first, int is_small) { @@ -52,8 +47,8 @@ int get_prev_alloc(t_alloc **alloc, t_alloc **res, t_alloc *cur, char *fnc) *res = cur; return (1); } - if ((cur->next > *alloc || cur->next == 0) && cur <= *alloc && ((t_ul)*alloc - \ - (t_ul)cur) <= cur->size) + if ((cur->next > *alloc || cur->next == 0) && cur <= *alloc && \ + ((t_ul)(*alloc) - (t_ul)cur) <= cur->size) { *alloc = cur; *res = prev; diff --git a/srcs/realloc.c b/srcs/realloc.c index 4aa8317..a3d65de 100644 --- a/srcs/realloc.c +++ b/srcs/realloc.c @@ -6,14 +6,15 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/02 14:41:22 by tomoron #+# #+# */ -/* Updated: 2024/12/04 17:22:37 by tomoron ### ########.fr */ +/* Updated: 2024/12/04 18:50:45 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include "includes/malloc.h" t_mem_chunk *get_alloc_chunk(t_alloc *alloc, t_mem_chunk *first, size_t size); -int get_prev_alloc(t_alloc **alloc, t_alloc **res, t_alloc *cur, char *fnc); +int get_prev_alloc(t_alloc **alloc, t_alloc **res, t_alloc *cur, \ + char *fnc); static void *realloc_recreate(t_alloc *alloc, size_t size) { diff --git a/srcs/utils.c b/srcs/utils.c index 09dd18c..8e85871 100644 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/12/03 13:20:54 by tomoron #+# #+# */ -/* Updated: 2024/12/03 13:23:31 by tomoron ### ########.fr */ +/* Updated: 2024/12/04 18:52:46 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,3 +18,9 @@ size_t align(size_t nb, size_t align_nb) nb = nb + (align_nb - (nb % align_nb)); return (nb); } + +void invalid_pointer(char *fnc) +{ + write(2, fnc, ft_strlen(fnc)); + write(2, "(): invalid pointer\n", 21); +}