path: root/src/malloc/memalign.c
diff options
authorRich Felker <>2018-04-19 20:56:26 -0400
committerRich Felker <>2018-04-19 20:56:26 -0400
commit72141795d4edd17f88da192447395a48444afa10 (patch)
tree483162056393cc2f4f380216781726531f76b94e /src/malloc/memalign.c
parent3c2cbbe7ba8b4486299ae0d5336ae01ab520d116 (diff)
return chunks split off by memalign using __bin_chunk instead of free
this change serves multiple purposes: 1. it ensures that static linking of memalign-family functions will pull in the system malloc implementation, thereby causing link errors if an attempt is made to link the system memalign functions with a replacement malloc (incomplete allocator replacement). 2. it eliminates calls to free that are unpaired with allocations, which are confusing when setting breakpoints or tracing execution. as a bonus, making __bin_chunk external may discourage aggressive and unnecessary inlining of it.
Diffstat (limited to 'src/malloc/memalign.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/src/malloc/memalign.c b/src/malloc/memalign.c
index 9c420229..7246a99b 100644
--- a/src/malloc/memalign.c
+++ b/src/malloc/memalign.c
@@ -48,7 +48,7 @@ void *__memalign(size_t align, size_t len)
n->psize = c->csize = C_INUSE | (new-mem);
n->csize = t->psize -= new-mem;
- free(mem);
+ __bin_chunk(c);
return new;