finish README.md and tests and fix makefile relink for tests rule
This commit is contained in:
5
Makefile
5
Makefile
@ -42,9 +42,8 @@ LFT_DIR = libft/
|
|||||||
|
|
||||||
all: libft_malloc.so
|
all: libft_malloc.so
|
||||||
|
|
||||||
exec: $(OBJS_DIR) $(NAME) $(LFT)
|
tests: $(OBJS_DIR) $(NAME) $(LFT) tests.c
|
||||||
# $(CC) -o a.out $(FLAGS) main.c $(NAME) $(LFT)
|
$(CC) -o tests $(FLAGS) tests.c -L. -lft_malloc $(LFT) -Wl,-rpath=.
|
||||||
$(CC) -o a.out $(FLAGS) tests.c -L. -lft_malloc $(LFT) -Wl,-rpath=.
|
|
||||||
|
|
||||||
libft_malloc.so: $(NAME)
|
libft_malloc.so: $(NAME)
|
||||||
ln -sf "$(NAME)" libft_malloc.so
|
ln -sf "$(NAME)" libft_malloc.so
|
||||||
|
@ -13,6 +13,12 @@ to override the functions in an already compile program you need to do this comm
|
|||||||
export LD_LIBRARY_PATH=. LD_PRELOAD=libft_malloc.so
|
export LD_LIBRARY_PATH=. LD_PRELOAD=libft_malloc.so
|
||||||
```
|
```
|
||||||
|
|
||||||
|
to compile a program with the lib, you have to add these parameters at the end of your compilation command (for gcc or clang):
|
||||||
|
|
||||||
|
```
|
||||||
|
-L<folder> -lft_malloc
|
||||||
|
```
|
||||||
|
|
||||||
## tests
|
## tests
|
||||||
a test program is available at the root. to execute it do the command `make test` and then execute the program that have been compiled with `./tests`
|
a test program is available at the root. to execute it do the command `make test` and then execute the program that have been compiled with `./tests`
|
||||||
|
|
||||||
|
7
tests.c
7
tests.c
@ -6,7 +6,7 @@
|
|||||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/20 17:58:16 by tomoron #+# #+# */
|
/* Created: 2025/03/20 17:58:16 by tomoron #+# #+# */
|
||||||
/* Updated: 2025/03/20 17:58:17 by tomoron ### ########.fr */
|
/* Updated: 2025/03/21 13:13:33 by tomoron ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -68,6 +68,7 @@ void show_alloc_ex_test()
|
|||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
|
printf("\n\n\nSHOW_ALLOC_EX TEST:\n");
|
||||||
data = malloc(1020);
|
data = malloc(1020);
|
||||||
memset(data, 0, 1020);
|
memset(data, 0, 1020);
|
||||||
strcpy(data, "0123456789abcdef");
|
strcpy(data, "0123456789abcdef");
|
||||||
@ -82,8 +83,8 @@ int main(void)
|
|||||||
realloc_test();
|
realloc_test();
|
||||||
show_alloc_ex_test();
|
show_alloc_ex_test();
|
||||||
|
|
||||||
#ifdef LEAK_TEST
|
#if 1
|
||||||
printf("leak_test set, allocating memory before end of program");
|
printf("allocating memory before end of program\n");
|
||||||
malloc(10);
|
malloc(10);
|
||||||
malloc(50);
|
malloc(50);
|
||||||
malloc(8000);
|
malloc(8000);
|
||||||
|
Reference in New Issue
Block a user