mirror of
https://git.musl-libc.org/git/musl
synced 2025-02-15 17:54:23 +03:00
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.
This commit is contained in:
parent
de798308e8
commit
d1e6fdd367
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user