From a24acfd0a1935d0e2fc36e1c8113eacfd407e853 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Sat, 30 Sep 2017 13:24:43 +0200 Subject: [PATCH] minor stuff --- malloc/Makefile | 4 +++- malloc/libft | 2 +- malloc/run.sh | 9 +++++++-- malloc/srcs/error_lib.c | 4 ++-- malloc/tests/test3.5.c | 6 ++++-- malloc/tests/test3.c | 7 +++++-- malloc/tests/test4.c | 2 ++ 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/malloc/Makefile b/malloc/Makefile index 71ce5fc7..fdf8fae6 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -18,7 +18,7 @@ NAME_BIS = libft_malloc.so NAME = libft_malloc_$(HOSTTYPE).so CC = gcc -FLAGS = -Wall -Wextra -Werror #-fsanitize=address +FLAGS = -Wall -Wextra -Werror -fPIC #-fsanitize=address MAIN_FLAGS = -shared OBJ_FLAGS = @@ -49,6 +49,8 @@ OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o)) NB = $(words $(SRC_BASE)) INDEX = 0 +SHELL := /bin/bash + all : @make -C $(LIBFT_DIR) @make -j $(NAME) diff --git a/malloc/libft b/malloc/libft index 3cfcbb41..8c0961c5 160000 --- a/malloc/libft +++ b/malloc/libft @@ -1 +1 @@ -Subproject commit 3cfcbb41103be5a16a8666b317ee397e9886fa4f +Subproject commit 8c0961c50468d42c3527c208d7f4ae3c98646882 diff --git a/malloc/run.sh b/malloc/run.sh index 2e07e1e0..4274f21d 100755 --- a/malloc/run.sh +++ b/malloc/run.sh @@ -1,2 +1,7 @@ -#!/bin/sh -DYLD_LIBRARY_PATH=. DYLD_INSERT_LIBRARIES="libft_malloc.so" DYLD_FORCE_FLAT_NAMESPACE=1 $@ +#!/bin/bash +if [[ `uname` == 'Darwin' ]]; then + DYLD_LIBRARY_PATH=. DYLD_INSERT_LIBRARIES="libft_malloc.so" DYLD_FORCE_FLAT_NAMESPACE=1 $@ +else + echo $PWD + LD_LIBRARY_PATH=$PWD/. $@ +fi diff --git a/malloc/srcs/error_lib.c b/malloc/srcs/error_lib.c index adcacf30..b572e94c 100644 --- a/malloc/srcs/error_lib.c +++ b/malloc/srcs/error_lib.c @@ -16,7 +16,7 @@ void error_free_notalloc(void *ptr) { int fd; - fd = 1; + fd = 2; ft_putstr_fd(FG_RED"(", fd); ft_putnbr_fd(getpid(), fd); ft_putstr_fd(", ??? ", fd); @@ -31,7 +31,7 @@ void error_mmap(void) { int fd; - fd = 1; + fd = 2; ft_putstr_fd(FG_RED"(", fd); ft_putnbr_fd(getpid(), fd); ft_putstr_fd(", ??? ", fd); diff --git a/malloc/tests/test3.5.c b/malloc/tests/test3.5.c index 302b3945..c2c16583 100644 --- a/malloc/tests/test3.5.c +++ b/malloc/tests/test3.5.c @@ -1,4 +1,6 @@ #include "../includes/malloc.h" +#include +#include #define M (1024 * 1024) @@ -17,8 +19,8 @@ int main(void) strcpy(addr1, "Bonjours\n"); print(addr1); addr2 = (char*)malloc(16*M); - addr3 = (char*)realloc(addr, 128*M); + addr3 = (char*)realloc(addr1, 128*M); addr3[127*M] = 42; - printf(addr3); + print(addr3); return (0); } diff --git a/malloc/tests/test3.c b/malloc/tests/test3.c index 93f1cc1d..8381fa06 100644 --- a/malloc/tests/test3.c +++ b/malloc/tests/test3.c @@ -1,4 +1,7 @@ #include "../includes/malloc.h" +#include +#include +#include #define M (1024 * 1024) @@ -15,8 +18,8 @@ int main(void) addr1 = (char*)malloc(16*M); strcpy(addr1, "Bonjours\n"); print(addr1); - addr3 = (char*)realloc(addr, 128*M); + addr3 = (char*)realloc(addr1, 128*M); addr3[127*M] = 42; - printf(addr3); + print(addr3); return (0); } diff --git a/malloc/tests/test4.c b/malloc/tests/test4.c index f150e7a6..9bb9f3d1 100644 --- a/malloc/tests/test4.c +++ b/malloc/tests/test4.c @@ -1,4 +1,6 @@ #include "../includes/malloc.h" +#include +#include void print(char *s) {