summaryrefslogtreecommitdiffstats
path: root/libc/stdlib/malloc-standard/memalign.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 16:47:01 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-07-09 16:47:01 +0000
commit62a21af8006ab04282fdc354c5b4dc765f56d058 (patch)
tree568761d58289238aa14cced3f0010809d4d28c00 /libc/stdlib/malloc-standard/memalign.c
parentef250238dc1572caf859c2b64652f9cdfb0d9e42 (diff)
downloaduClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.bz2
uClibc-alpine-62a21af8006ab04282fdc354c5b4dc765f56d058.tar.xz
BIG BIG commit: all left files merged from trunk [rev 22714]. Currenntly NPTL sh4 port build and work fine. All committed to allow Khem Ray working on a working branch to integrate the ARM nptl port. MIPS nptl port not tested but should still building and working fine. There are some other part non yet merged with trunk (misc/internals and some headers file that need some more work). Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/stdlib/malloc-standard/memalign.c')
-rw-r--r--libc/stdlib/malloc-standard/memalign.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libc/stdlib/malloc-standard/memalign.c b/libc/stdlib/malloc-standard/memalign.c
index 27502893d..7e0674be5 100644
--- a/libc/stdlib/malloc-standard/memalign.c
+++ b/libc/stdlib/malloc-standard/memalign.c
@@ -35,6 +35,7 @@ void* memalign(size_t alignment, size_t bytes)
mchunkptr remainder; /* spare room at end to split off */
unsigned long remainder_size; /* its size */
size_t size;
+ void *retval;
/* If need less alignment than we give anyway, just relay to malloc */
@@ -51,7 +52,7 @@ void* memalign(size_t alignment, size_t bytes)
alignment = a;
}
- LOCK;
+ __MALLOC_LOCK;
checked_request2size(bytes, nb);
/* Strategy: find a spot within that chunk that meets the alignment
@@ -63,8 +64,8 @@ void* memalign(size_t alignment, size_t bytes)
m = (char*)(malloc(nb + alignment + MINSIZE));
if (m == 0) {
- UNLOCK;
- return 0; /* propagate failure */
+ retval = 0; /* propagate failure */
+ goto DONE;
}
p = mem2chunk(m);
@@ -92,8 +93,8 @@ void* memalign(size_t alignment, size_t bytes)
if (chunk_is_mmapped(p)) {
newp->prev_size = p->prev_size + leadsize;
set_head(newp, newsize|IS_MMAPPED);
- UNLOCK;
- return chunk2mem(newp);
+ retval = chunk2mem(newp);
+ goto DONE;
}
/* Otherwise, give back leader, use the rest */
@@ -120,7 +121,10 @@ void* memalign(size_t alignment, size_t bytes)
}
check_inuse_chunk(p);
- UNLOCK;
- return chunk2mem(p);
+ retval = chunk2mem(p);
+
+ DONE:
+ __MALLOC_UNLOCK;
+ return retval;
}