Fix portable build.
Move dlmalloc include inside of cc file.
Change-Id: Ic36bdbf9fa964b93a23d1a45f603bab1bf9583d7
diff --git a/runtime/gc/accounting/gc_allocator.cc b/runtime/gc/accounting/gc_allocator.cc
index aff50df..0b0d3ed 100644
--- a/runtime/gc/accounting/gc_allocator.cc
+++ b/runtime/gc/accounting/gc_allocator.cc
@@ -15,18 +15,21 @@
*/
#include "gc_allocator.h"
+#include "gc/allocator/dlmalloc.h"
#include "gc/heap.h"
#include "runtime.h"
namespace art {
namespace gc {
namespace accounting {
- void RegisterGCAllocation(size_t bytes) {
+ void* RegisterGCAllocation(size_t bytes) {
Runtime::Current()->GetHeap()->RegisterGCAllocation(bytes);
+ return malloc(bytes);
}
- void RegisterGCDeAllocation(size_t bytes) {
+ void RegisterGCDeAllocation(void* p, size_t bytes) {
Runtime::Current()->GetHeap()->RegisterGCDeAllocation(bytes);
+ free(p);
}
}
}
diff --git a/runtime/gc/accounting/gc_allocator.h b/runtime/gc/accounting/gc_allocator.h
index 1cfcf43..d1356a7 100644
--- a/runtime/gc/accounting/gc_allocator.h
+++ b/runtime/gc/accounting/gc_allocator.h
@@ -17,7 +17,6 @@
#ifndef ART_RUNTIME_GC_ACCOUNTING_GC_ALLOCATOR_H_
#define ART_RUNTIME_GC_ACCOUNTING_GC_ALLOCATOR_H_
-#include "gc/allocator/dlmalloc.h"
#include "utils.h"
#include <cstdlib>
@@ -27,8 +26,8 @@
namespace art {
namespace gc {
namespace accounting {
- void RegisterGCAllocation(size_t bytes);
- void RegisterGCDeAllocation(size_t bytes);
+ void* RegisterGCAllocation(size_t bytes);
+ void RegisterGCDeAllocation(void* p, size_t bytes);
static const bool kMeasureGCMemoryOverhead = false;
@@ -60,14 +59,12 @@
};
pointer allocate(size_type n, const_pointer hint = 0) {
- RegisterGCAllocation(n * sizeof(T));
- return reinterpret_cast<pointer>(malloc(n * sizeof(T)));
+ return reinterpret_cast<pointer>(RegisterGCAllocation(n * sizeof(T)));
}
template <typename PT>
void deallocate(PT p, size_type n) {
- RegisterGCDeAllocation(n * sizeof(T));
- free(p);
+ RegisterGCDeAllocation(p, n * sizeof(T));
}
};
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 853db93..20512b8 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -24,7 +24,6 @@
#include "atomic_integer.h"
#include "base/timing_logger.h"
#include "gc/accounting/atomic_stack.h"
-#include "gc/accounting/gc_allocator.h"
#include "gc/accounting/card_table.h"
#include "gc/collector/gc_type.h"
#include "globals.h"