about summary refs log tree commit diff
path: root/src/malloc/oldmalloc
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2020-06-10 20:44:51 -0400
committerRich Felker <dalias@aerifal.cx>2020-06-10 20:51:17 -0400
commit25cef5c591fbee755a53f0d7920f4f554f343a53 (patch)
tree13b38ac1a7522dcc2f988407187a98bc0612a888 /src/malloc/oldmalloc
parent501a92660ca2ed6469a0a01474574ce9930356cd (diff)
downloadmusl-25cef5c591fbee755a53f0d7920f4f554f343a53.tar.gz
musl-25cef5c591fbee755a53f0d7920f4f554f343a53.tar.xz
musl-25cef5c591fbee755a53f0d7920f4f554f343a53.zip
reintroduce calloc elison of memset for direct-mmapped allocations
a new weak predicate function replacable by the malloc implementation,
__malloc_allzerop, is introduced. by default it's always false; the
default version will be used when static linking if the bump allocator
was used (in which case performance doesn't matter) or if malloc was
replaced by the application. only if the real internal malloc is
linked (always the case with dynamic linking) does the real version
get used.

if malloc was replaced dynamically, as indicated by __malloc_replaced,
the predicate function is ignored and conditional-memset is always
performed.
Diffstat (limited to 'src/malloc/oldmalloc')
-rw-r--r--src/malloc/oldmalloc/malloc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/malloc/oldmalloc/malloc.c b/src/malloc/oldmalloc/malloc.c
index 1c6b07ec..0a38690c 100644
--- a/src/malloc/oldmalloc/malloc.c
+++ b/src/malloc/oldmalloc/malloc.c
@@ -339,6 +339,11 @@ void *malloc(size_t n)
 	return CHUNK_TO_MEM(c);
 }
 
+int __malloc_allzerop(void *p)
+{
+	return IS_MMAPPED(MEM_TO_CHUNK(p));
+}
+
 void *realloc(void *p, size_t n)
 {
 	struct chunk *self, *next;