From 7629201717eb056823924eda00e291857026191f Mon Sep 17 00:00:00 2001 From: Guillem George Date: Tue, 4 Nov 2025 19:13:31 +0100 Subject: [PATCH] ' --- malloc/Makefile | 10 ++++++---- malloc/src/helpers/helpers.c | 4 ++++ malloc/src/helpers/helpers.h | 8 ++++++++ malloc/src/malloc.c | 3 ++- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 malloc/src/helpers/helpers.c create mode 100644 malloc/src/helpers/helpers.h diff --git a/malloc/Makefile b/malloc/Makefile index 65f356b..6334b0d 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -1,15 +1,17 @@ CC=gcc -CFLAGS= -LDFLAGS= +CFLAGS=-std=c99 -pedantic -Werror -Wall -Wextra -Wvla -fvisibility=hidden -fPIC +CPPFLAGS=D_DEFAULT_SOURCE +LDFLAGS= -shared -Wl --no-undefined SRCS= OBJS=${SRC:.c=.o} TARGET=libmalloc.so library: $(OBJS) - $(CC) -shared -o $(TARGET) $^ + $(CC) -o $(TARGET) $^ -debug: +debug: $(OBJS) $(TST_OBJS) + $(CC) -o $(TST_TARGET) $^ check: diff --git a/malloc/src/helpers/helpers.c b/malloc/src/helpers/helpers.c new file mode 100644 index 0000000..bba1bc1 --- /dev/null +++ b/malloc/src/helpers/helpers.c @@ -0,0 +1,4 @@ +#include "helpers.h" + +size_t get_next_2power(size_t n) +{} diff --git a/malloc/src/helpers/helpers.h b/malloc/src/helpers/helpers.h new file mode 100644 index 0000000..4d5b403 --- /dev/null +++ b/malloc/src/helpers/helpers.h @@ -0,0 +1,8 @@ +#ifndef HELPERS_H +#define HELPERS_H + +#include + +size_t get_next_2power(size_t n); + +#endif // ! HELPERS_H diff --git a/malloc/src/malloc.c b/malloc/src/malloc.c index 8b99ad9..26e8ab1 100644 --- a/malloc/src/malloc.c +++ b/malloc/src/malloc.c @@ -2,7 +2,8 @@ __attribute__((visibility("default"))) void *malloc(size_t size) { - return NULL; + if (size == 0) + return NULL; } __attribute__((visibility("default"))) void free(void *ptr)