summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-standard
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-03-29 04:50:56 -0500
committerWaldemar Brodkorb <wbx@openadk.org>2015-03-29 04:50:56 -0500
commitcd5f92704e1e17bbc0c15d197f3bc236c7dc9bf2 (patch)
tree1400302b543e4528aedea5d72731983559cfcf36 /libc/stdlib/malloc-standard
parentad2bffbf1926051ef333f9899344f6bddf2c03cf (diff)
parent24946289317ea23bb0d1814cca0a499a905f7d6f (diff)
merge uClibc git master
Diffstat (limited to 'libc/stdlib/malloc-standard')
-rw-r--r--libc/stdlib/malloc-standard/free.c6
-rw-r--r--libc/stdlib/malloc-standard/malloc.c5
-rw-r--r--libc/stdlib/malloc-standard/memalign.c2
-rw-r--r--libc/stdlib/malloc-standard/realloc.c2
4 files changed, 10 insertions, 5 deletions
diff --git a/libc/stdlib/malloc-standard/free.c b/libc/stdlib/malloc-standard/free.c
index 39e54d635..8b7a81fca 100644
--- a/libc/stdlib/malloc-standard/free.c
+++ b/libc/stdlib/malloc-standard/free.c
@@ -104,9 +104,13 @@ static int __malloc_trim(size_t pad, mstate av)
*/
int malloc_trim(size_t pad)
{
+ int r;
+ __MALLOC_LOCK;
mstate av = get_malloc_state();
__malloc_consolidate(av);
- return __malloc_trim(pad, av);
+ r = __malloc_trim(pad, av);
+ __MALLOC_UNLOCK;
+ return r;
}
/*
diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c
index 2abb5bbdd..fd33b50c7 100644
--- a/libc/stdlib/malloc-standard/malloc.c
+++ b/libc/stdlib/malloc-standard/malloc.c
@@ -832,8 +832,6 @@ void* malloc(size_t bytes)
}
#endif
- __MALLOC_LOCK;
- av = get_malloc_state();
/*
Convert request size to internal form by adding (sizeof(size_t)) bytes
overhead plus possibly more to obtain necessary alignment and/or
@@ -845,6 +843,9 @@ void* malloc(size_t bytes)
checked_request2size(bytes, nb);
+ __MALLOC_LOCK;
+ av = get_malloc_state();
+
/*
Bypass search if no frees yet
*/
diff --git a/libc/stdlib/malloc-standard/memalign.c b/libc/stdlib/malloc-standard/memalign.c
index 6303c1dd9..e9ae5a7b9 100644
--- a/libc/stdlib/malloc-standard/memalign.c
+++ b/libc/stdlib/malloc-standard/memalign.c
@@ -52,8 +52,8 @@ void* memalign(size_t alignment, size_t bytes)
alignment = a;
}
- __MALLOC_LOCK;
checked_request2size(bytes, nb);
+ __MALLOC_LOCK;
/* Strategy: find a spot within that chunk that meets the alignment
* request, and then possibly free the leading and trailing space. */
diff --git a/libc/stdlib/malloc-standard/realloc.c b/libc/stdlib/malloc-standard/realloc.c
index e060b70ea..e49d11125 100644
--- a/libc/stdlib/malloc-standard/realloc.c
+++ b/libc/stdlib/malloc-standard/realloc.c
@@ -54,9 +54,9 @@ void* realloc(void* oldmem, size_t bytes)
return NULL;
}
+ checked_request2size(bytes, nb);
__MALLOC_LOCK;
av = get_malloc_state();
- checked_request2size(bytes, nb);
oldp = mem2chunk(oldmem);
oldsize = chunksize(oldp);