From 6bba9ea6d8fe8ff358421521b253296ea8b2fb53 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Wed, 17 Dec 2014 03:52:59 -0500 Subject: [PATCH] Added yatest --- .gitignore | 1 + Makefile | 18 ++++++++++++++++++ yatest.c | 26 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 Makefile create mode 100644 yatest.c diff --git a/.gitignore b/.gitignore index 3e012f8..b121431 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ *.i*86 *.x86_64 *.hex +yatest # Fuse hidden files .fuse* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5d7a25d --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +CC=`which gcc` +CPPFLAGS=-DYA_DEBUG +CFLAGS=--std=c11 -ggdb + +all: yatest + +test: yatest + ./yatest + +%.o: %.c + $(CC) -c $^ $(CPPFLAGS) $(CFLAGS) + +yatest: yatest.o yamalloc.o + $(CC) -o $@ $^ $(CFLAGS) + +clean: + rm -f *.o + rm -f yatest diff --git a/yatest.c b/yatest.c new file mode 100644 index 0000000..77d2b45 --- /dev/null +++ b/yatest.c @@ -0,0 +1,26 @@ +/* + * Yet Another Malloc + * yatest.c + * Author: Titouan Rigoudy +*/ + +#include + +#include "yamalloc.h" + +void *print_malloc(size_t size) { + void *ptr = malloc(size); + printf("malloc(%ld) = %p\n", size, ptr); + return ptr; +} + +int main(int argc, char **argv) { + ya_print_blocks(); + print_malloc(4); + print_malloc(10); + ya_print_blocks(); + print_malloc(10000); + ya_print_blocks(); + print_malloc(2000); + ya_print_blocks(); +}