Skip to content

Commit

Permalink
[BZ #2684]
Browse files Browse the repository at this point in the history
2006-08-27  Ulrich Drepper  <drepper@redhat.com>
	[BZ #2684]
	* malloc/malloc.c (public_rEALLOc): Try harder by using other
	arenas if allocation failed.
	Patch mostly by Jan Edler <jan.edler@indexengines.com>.
  • Loading branch information
Ulrich Drepper committed Aug 28, 2006
1 parent 41999a1 commit 07014fc
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2006-08-27 Ulrich Drepper <drepper@redhat.com>

[BZ #2684]
* malloc/malloc.c (public_rEALLOc): Try harder by using other
arenas if allocation failed.
Patch mostly by Jan Edler <jan.edler@indexengines.com>.

2006-08-26 Ulrich Drepper <drepper@redhat.com>

* malloc/malloc.c (bin_at): Rewrite to be more clear and to not
23 changes: 23 additions & 0 deletions malloc/malloc.c
Original file line number Diff line number Diff line change
@@ -3625,6 +3625,29 @@ public_rEALLOc(Void_t* oldmem, size_t bytes)
(void)mutex_unlock(&ar_ptr->mutex);
assert(!newp || chunk_is_mmapped(mem2chunk(newp)) ||
ar_ptr == arena_for_chunk(mem2chunk(newp)));

if (newp == NULL)
{
/* Try harder to allocate memory in other arenas. */
newp = public_mALLOc(bytes);
if (newp != NULL)
{
MALLOC_COPY (newp, oldmem, oldsize - 2 * SIZE_SZ);
#if THREAD_STATS
if(!mutex_trylock(&ar_ptr->mutex))
++(ar_ptr->stat_lock_direct);
else {
(void)mutex_lock(&ar_ptr->mutex);
++(ar_ptr->stat_lock_wait);
}
#else
(void)mutex_lock(&ar_ptr->mutex);
#endif
_int_free(ar_ptr, oldmem);
(void)mutex_unlock(&ar_ptr->mutex);
}
}

return newp;
}
#ifdef libc_hidden_def

0 comments on commit 07014fc

Please sign in to comment.