diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2023-03-25 00:04:55 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2023-03-25 00:04:55 +0300 |
commit | 132eb0bc220b7c2e32d43e9e5c290b17a7e6f37a (patch) | |
tree | 9573042accd1de1d68d0132b429e85d3f445594d /malloc.c | |
parent | 55dbba223f8790e07ab83a1ced9a17fe99f9ed00 (diff) | |
download | bdwgc-132eb0bc220b7c2e32d43e9e5c290b17a7e6f37a.tar.gz |
Do not add extra byte to non-small uncollectible objects
Previously EXTRA_BYTES value was not added to the allocation size only
for small uncollectible objects.
* include/gc/gc.h (GC_all_interior_pointers): Refine comment (regarding
uncollectible objects).
* malloc.c (GC_generic_malloc_uncollectable): Define lb_orig local
variable; decrement lb before if(SMALL_OBJ(lb)); do not expect original
lb is zero; pass lb_orig (instead of lb) to GC_DBG_COLLECT_AT_MALLOC()
and to oom_fn().
Diffstat (limited to 'malloc.c')
-rw-r--r-- | malloc.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -338,8 +338,13 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc_uncollectable( size_t lb, int k) { void *op; + size_t lb_orig = lb; GC_ASSERT(k < MAXOBJKINDS); + if (EXTRA_BYTES != 0 && EXPECT(lb != 0, TRUE)) lb--; + /* We do not need the extra byte, since this will */ + /* not be collected anyway. */ + if (SMALL_OBJ(lb)) { void **opp; size_t lg; @@ -347,10 +352,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc_uncollectable( if (EXPECT(get_have_errors(), FALSE)) GC_print_all_errors(); GC_INVOKE_FINALIZERS(); - GC_DBG_COLLECT_AT_MALLOC(lb); - if (EXTRA_BYTES != 0 && lb != 0) lb--; - /* We don't need the extra byte, since this won't be */ - /* collected anyway. */ + GC_DBG_COLLECT_AT_MALLOC(lb_orig); LOCK(); lg = GC_size_map[lb]; opp = &GC_obj_kinds[k].ok_freelist[lg]; @@ -368,7 +370,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_generic_malloc_uncollectable( if (NULL == op) { GC_oom_func oom_fn = GC_oom_fn; UNLOCK(); - return (*oom_fn)(lb); + return (*oom_fn)(lb_orig); } /* For small objects, the free lists are completely marked. */ } |