static jboolean addObjectGCRoot(Env* env, void* ptr, void*** roots, jint* count, jint* size, jint initialSize) { jint index = *count; if (index >= *size) { jint newSize = *size > 0 ? (*size << 1) : initialSize; void** tmp = rvmAllocateMemoryUncollectable(env, newSize * sizeof(void*)); if (!tmp) { return FALSE; } TRACEF("Object GC roots grown from %d to %d total entries", *size, newSize); if (*roots) { memcpy(tmp, *roots, *size * sizeof(void*)); rvmFreeMemoryUncollectable(env, *roots); } *roots = tmp; *size = newSize; } (*roots)[index] = ptr; *count = index + 1; return TRUE; }
jlong Java_aura_rt_VM_allocateMemoryUncollectable(Env* env, Class* c, jint size) { return PTR_TO_LONG(rvmAllocateMemoryUncollectable(env, size)); }