namespace accounting {
void* RegisterGcAllocation(size_t bytes) {
- Runtime::Current()->GetHeap()->RegisterGCAllocation(bytes);
+ gc::Heap* heap = Runtime::Current()->GetHeap();
+ if (heap != nullptr) {
+ heap->RegisterGCAllocation(bytes);
+ }
return malloc(bytes);
}
void RegisterGcDeallocation(void* p, size_t bytes) {
- Runtime::Current()->GetHeap()->RegisterGCDeAllocation(bytes);
+ gc::Heap* heap = Runtime::Current()->GetHeap();
+ if (heap != nullptr) {
+ heap->RegisterGCDeAllocation(bytes);
+ }
free(p);
}
void* RegisterGcAllocation(size_t bytes);
void RegisterGcDeallocation(void* p, size_t bytes);
-static const bool kMeasureGcMemoryOverhead = false;
+static constexpr bool kMeasureGcMemoryOverhead = false;
template <typename T>
class GcAllocatorImpl : public std::allocator<T> {