Index: runtime/vm/dart_api_impl.cc |
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
index 8ff2deb5d67f79af18fbb3ae1cc7074d99718e6e..38123f713854875c7fc62e68a45e23e7b5695f8d 100644 |
--- a/runtime/vm/dart_api_impl.cc |
+++ b/runtime/vm/dart_api_impl.cc |
@@ -1780,12 +1780,19 @@ DART_EXPORT bool Dart_HasLivePorts() { |
} |
-static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
+static uint8_t* malloc_allocator(uint8_t* ptr, |
+ intptr_t old_size, |
+ intptr_t new_size) { |
void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); |
return reinterpret_cast<uint8_t*>(new_ptr); |
} |
+static void malloc_deallocator(uint8_t* ptr) { |
+ free(reinterpret_cast<void*>(ptr)); |
+} |
+ |
+ |
DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { |
DARTSCOPE(Thread::Current()); |
API_TIMELINE_DURATION; |
@@ -1803,7 +1810,7 @@ DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { |
const Object& object = Object::Handle(Z, raw_obj); |
uint8_t* data = NULL; |
- MessageWriter writer(&data, &allocator, false); |
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false); |
writer.WriteMessage(object); |
intptr_t len = writer.BytesWritten(); |
return PortMap::PostMessage( |