From 384c0131ccda2656dec23a0416ad3f14101151a7 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 3 Jun 2020 19:22:12 -0400
Subject: [PATCH] move oldmalloc to its own directory under src/malloc

this sets the stage for replacement, and makes it practical to keep
oldmalloc around as a build option for a while if that ends up being
useful.

only the files which are actually part of the implementation are
moved. memalign and posix_memalign are entirely generic. in theory
calloc could be pulled out too, but it's useful to have it tied to the
implementation so as to optimize out unnecessary memset when
implementation details make it possible to know the memory is already
clear.
---
 Makefile                                        | 3 ++-
 src/malloc/{ => oldmalloc}/aligned_alloc.c      | 0
 src/malloc/{ => oldmalloc}/malloc.c             | 0
 src/malloc/{ => oldmalloc}/malloc_impl.h        | 0
 src/malloc/{ => oldmalloc}/malloc_usable_size.c | 0
 5 files changed, 2 insertions(+), 1 deletion(-)
 rename src/malloc/{ => oldmalloc}/aligned_alloc.c (100%)
 rename src/malloc/{ => oldmalloc}/malloc.c (100%)
 rename src/malloc/{ => oldmalloc}/malloc_impl.h (100%)
 rename src/malloc/{ => oldmalloc}/malloc_usable_size.c (100%)

diff --git a/Makefile b/Makefile
index bd8f5c38..3d3e3622 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,8 @@ includedir = $(prefix)/include
 libdir = $(prefix)/lib
 syslibdir = /lib
 
-SRC_DIRS = $(addprefix $(srcdir)/,src/* crt ldso $(COMPAT_SRC_DIRS))
+MALLOC_DIR = oldmalloc
+SRC_DIRS = $(addprefix $(srcdir)/,src/* src/malloc/$(MALLOC_DIR) crt ldso $(COMPAT_SRC_DIRS))
 BASE_GLOBS = $(addsuffix /*.c,$(SRC_DIRS))
 ARCH_GLOBS = $(addsuffix /$(ARCH)/*.[csS],$(SRC_DIRS))
 BASE_SRCS = $(sort $(wildcard $(BASE_GLOBS)))
diff --git a/src/malloc/aligned_alloc.c b/src/malloc/oldmalloc/aligned_alloc.c
similarity index 100%
rename from src/malloc/aligned_alloc.c
rename to src/malloc/oldmalloc/aligned_alloc.c
diff --git a/src/malloc/malloc.c b/src/malloc/oldmalloc/malloc.c
similarity index 100%
rename from src/malloc/malloc.c
rename to src/malloc/oldmalloc/malloc.c
diff --git a/src/malloc/malloc_impl.h b/src/malloc/oldmalloc/malloc_impl.h
similarity index 100%
rename from src/malloc/malloc_impl.h
rename to src/malloc/oldmalloc/malloc_impl.h
diff --git a/src/malloc/malloc_usable_size.c b/src/malloc/oldmalloc/malloc_usable_size.c
similarity index 100%
rename from src/malloc/malloc_usable_size.c
rename to src/malloc/oldmalloc/malloc_usable_size.c