GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_kind_global(size_t lb, int k)
{
void *op;
+ void **opp;
size_t lg;
DCL_LOCK_STATE;
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
LOCK();
- op = GC_freelists[k][lg];
+ opp = &GC_obj_kinds[k].ok_freelist[lg];
+ op = *opp;
if (EXPECT(op != NULL, TRUE)) {
if (k == PTRFREE) {
- GC_freelists[k][lg] = obj_link(op);
+ *opp = obj_link(op);
} else {
GC_ASSERT(0 == obj_link(op)
|| ((word)obj_link(op)
<= (word)GC_greatest_plausible_heap_addr
&& (word)obj_link(op)
>= (word)GC_least_plausible_heap_addr));
- GC_freelists[k][lg] = obj_link(op);
+ *opp = obj_link(op);
obj_link(op) = 0;
}
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
size_t lb, int k)
{
void *op;
+ void **opp;
size_t lg;
DCL_LOCK_STATE;
/* collected anyway. */
lg = GC_size_map[lb];
LOCK();
- op = GC_freelists[k][lg];
+ opp = &GC_obj_kinds[k].ok_freelist[lg];
+ op = *opp;
if (EXPECT(op != NULL, TRUE)) {
- GC_freelists[k][lg] = obj_link(op);
+ *opp = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
/* Mark bit was already set on free list. It will be */
/* We hold the allocator lock. */
GC_INNER void GC_destroy_thread_local(GC_tlfs p)
{
- int i;
+ int k;
/* We currently only do this from the thread itself or from */
/* the fork handler for a child process. */
GC_STATIC_ASSERT(PREDEFINED_KINDS >= THREAD_FREELISTS_KINDS);
- for (i = 0; i < THREAD_FREELISTS_KINDS; ++i) {
- return_freelists(p -> _freelists[i], GC_freelists[i]);
+ for (k = 0; k < THREAD_FREELISTS_KINDS; ++k) {
+ if (k == (int)GC_n_kinds)
+ break; /* kind is not created */
+ return_freelists(p -> _freelists[k], GC_obj_kinds[k].ok_freelist);
}
# ifdef GC_GCJ_SUPPORT
return_freelists(p -> gcj_freelists, (void **)GC_gcjobjfreelist);