wip: tests: show more debug information

This commit is contained in:
Khaïs COLIN 2025-02-26 14:07:55 +01:00 committed by Khaïs COLIN
parent c57a4a69a7
commit d303f22b73
7 changed files with 99 additions and 5 deletions

View file

@ -6,7 +6,7 @@
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 16:06:09 by jguelen #+# #+# */
/* Updated: 2025/02/20 14:59:22 by khais ### ########.fr */
/* Updated: 2025/03/03 13:02:45 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -173,4 +173,42 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *));
/*frees two pointers and returns NULL*/
void *free2(void *p1, void *p2);
# include <stdio.h>
# include "../src/print_backtrace.h"
# define malloc(size) \
({ \
void * ret = malloc(size); \
if (!ret) \
fprintf(stderr, "malloc fail at %s:%d failed\n", \
__FILE__, __LINE__); \
else \
fprintf(stderr, "malloc at(%p) at %s:%d\n", \
ret, __FILE__, __LINE__); \
print_backtrace(); \
ret; \
})
# define ft_calloc(elmt_nbr, elmt_size) \
({ \
void * ret = ft_calloc(elmt_nbr, elmt_size); \
if (!ret) \
fprintf(stderr, "malloc fail at %s:%d failed\n", \
__FILE__, __LINE__); \
else \
fprintf(stderr, "ft_calloc at(%p) at %s:%d\n", \
ret, __FILE__, __LINE__); \
print_backtrace(); \
ret; \
})
# define free(ptr) \
({ \
fprintf(stderr, "free(%p) at %s:%d\n", \
ptr, __FILE__, __LINE__); \
print_backtrace(); \
free(ptr); \
})
#endif