summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorivmai <ivmai>2009-10-09 19:03:35 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:50 +0200
commit74c477acf8dc9b74994fb5fa6766e41e8ba54413 (patch)
treeb29f09534e9910956b7bbf53eb6e018575f877b1 /malloc.c
parent357bf758ba1c207ebeca4b276ef6a4aa9a5d2be0 (diff)
2009-10-09 Ivan Maidanski <ivmai@mail.ru>
* alloc.c (GC_collect_or_expand): Add "retry" argument; add the comments; don't use "default" stop_func on a retry if GC_dont_expand. * alloc.c (GC_collect_or_expand): Reformat the code (make the indentation style uniform across the function). * alloc.c (GC_allocobj): Pass "retry" argument to GC_collect_or_expand(). * malloc.c (GC_alloc_large): Ditto. * include/private/gc_priv.h (GC_collect_or_expand): Move the declaration to malloc.c; add "retry" argument.
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/malloc.c b/malloc.c
index 1264256..e8d397c 100644
--- a/malloc.c
+++ b/malloc.c
@@ -35,6 +35,9 @@ STATIC GC_bool GC_alloc_reclaim_list(struct obj_kind *kind)
return(TRUE);
}
+GC_bool GC_collect_or_expand(word needed_blocks, GC_bool ignore_off_page,
+ GC_bool retry); /* from alloc.c */
+
/* Allocate a large block of size lb bytes. */
/* The block is not cleared. */
/* Flags is 0 or IGNORE_OFF_PAGE. */
@@ -45,13 +48,14 @@ ptr_t GC_alloc_large(size_t lb, int k, unsigned flags)
struct hblk * h;
word n_blocks;
ptr_t result;
+ GC_bool retry = FALSE;
/* Round up to a multiple of a granule. */
lb = (lb + GRANULE_BYTES - 1) & ~(GRANULE_BYTES - 1);
n_blocks = OBJ_SZ_TO_BLOCKS(lb);
if (!GC_is_initialized) GC_init();
/* Do our share of marking work */
- if(GC_incremental && !GC_dont_gc)
+ if (GC_incremental && !GC_dont_gc)
GC_collect_a_little_inner((int)n_blocks);
h = GC_allochblk(lb, k, flags);
# ifdef USE_MUNMAP
@@ -60,8 +64,9 @@ ptr_t GC_alloc_large(size_t lb, int k, unsigned flags)
h = GC_allochblk(lb, k, flags);
}
# endif
- while (0 == h && GC_collect_or_expand(n_blocks, (flags != 0))) {
+ while (0 == h && GC_collect_or_expand(n_blocks, flags != 0, retry)) {
h = GC_allochblk(lb, k, flags);
+ retry = TRUE;
}
if (h == 0) {
result = 0;