diff options
author | Rich Felker <dalias@aerifal.cx> | 2020-06-03 19:11:23 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2020-06-03 19:11:23 -0400 |
commit | d1e6fdd3674eff0e09554c7ddc431acb8925232f (patch) | |
tree | 0181f78dc2700d2028eb2e354030c648326506a6 | |
parent | de798308e8a06608bb5a184dc209002ae1e0a142 (diff) | |
download | musl-d1e6fdd3674eff0e09554c7ddc431acb8925232f.tar.gz musl-d1e6fdd3674eff0e09554c7ddc431acb8925232f.tar.bz2 musl-d1e6fdd3674eff0e09554c7ddc431acb8925232f.tar.xz musl-d1e6fdd3674eff0e09554c7ddc431acb8925232f.zip |
reverse dependency order of memalign and aligned_alloc
this change eliminates the internal __memalign function and makes the
memalign and posix_memalign functions completely independent of the
malloc implementation, written portably in terms of aligned_alloc.
-rw-r--r-- | src/malloc/malloc_impl.h | 2 | ||||
-rw-r--r-- | src/malloc/memalign.c | 4 | ||||
-rw-r--r-- | src/malloc/memalign_altname.c | 6 | ||||
-rw-r--r-- | src/malloc/posix_memalign.c | 3 |
4 files changed, 5 insertions, 10 deletions
diff --git a/src/malloc/malloc_impl.h b/src/malloc/malloc_impl.h index 2c61b3ff..6a92c1c6 100644 --- a/src/malloc/malloc_impl.h +++ b/src/malloc/malloc_impl.h @@ -6,8 +6,6 @@ hidden void *__expand_heap(size_t *); -hidden void *__memalign(size_t, size_t); - struct chunk { size_t psize, csize; struct chunk *next, *prev; diff --git a/src/malloc/memalign.c b/src/malloc/memalign.c index cf9dfbda..e06c76ed 100644 --- a/src/malloc/memalign.c +++ b/src/malloc/memalign.c @@ -3,7 +3,7 @@ #include <errno.h> #include "malloc_impl.h" -void *__memalign(size_t align, size_t len) +void *aligned_alloc(size_t align, size_t len) { unsigned char *mem, *new; @@ -50,5 +50,3 @@ void *__memalign(size_t align, size_t len) __bin_chunk(c); return new; } - -weak_alias(__memalign, memalign); diff --git a/src/malloc/memalign_altname.c b/src/malloc/memalign_altname.c index b6143f30..32cd87d8 100644 --- a/src/malloc/memalign_altname.c +++ b/src/malloc/memalign_altname.c @@ -1,7 +1,7 @@ +#define _BSD_SOURCE #include <stdlib.h> -#include "malloc_impl.h" -void *aligned_alloc(size_t align, size_t len) +void *memalign(size_t align, size_t len) { - return __memalign(align, len); + return aligned_alloc(align, len); } diff --git a/src/malloc/posix_memalign.c b/src/malloc/posix_memalign.c index 2ea8bd8a..ad4d8f47 100644 --- a/src/malloc/posix_memalign.c +++ b/src/malloc/posix_memalign.c @@ -1,11 +1,10 @@ #include <stdlib.h> #include <errno.h> -#include "malloc_impl.h" int posix_memalign(void **res, size_t align, size_t len) { if (align < sizeof(void *)) return EINVAL; - void *mem = __memalign(align, len); + void *mem = aligned_alloc(align, len); if (!mem) return errno; *res = mem; return 0; |