summaryrefslogtreecommitdiff
path: root/libc/stdlib/malloc-standard
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-03-18 23:11:39 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2015-03-18 23:11:39 +0100
commitbe61486447ab447ac24892845af92489fe0b7148 (patch)
tree1ace9d2c3b8e35544dc770f4ca33618d662c6949 /libc/stdlib/malloc-standard
parent85cfbc035370d2a3715ea9de3e590ba83fae52d1 (diff)
malloc-standard: Add locking to malloc_trim
Closes bugzilla #4586 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/stdlib/malloc-standard')
-rw-r--r--libc/stdlib/malloc-standard/free.c6
1 files changed, 5 insertions, 1 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;
}
/*