Index: runtime/lib/isolate.cc |
diff --git a/runtime/lib/isolate.cc b/runtime/lib/isolate.cc |
index d88fbc8c5d6f8c10eb034326e417ce54501e0270..4eff30795a604e3d295aebcad0fc1e90b57a8fce 100644 |
--- a/runtime/lib/isolate.cc |
+++ b/runtime/lib/isolate.cc |
@@ -30,11 +30,17 @@ DEFINE_FLAG(bool, |
false, |
"Block the parent thread when loading spawned isolates."); |
-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)); |
+} |
+ |
DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) { |
ASSERT(TypeArguments::CheckedHandle(arguments->NativeArgAt(0)).IsNull()); |
@@ -116,7 +122,8 @@ DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 2) { |
new Message(destination_port_id, obj.raw(), Message::kNormalPriority)); |
} else { |
uint8_t* data = NULL; |
- MessageWriter writer(&data, &allocator, can_send_any_object); |
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, |
+ can_send_any_object); |
writer.WriteMessage(obj); |
// TODO(turnidge): Throw an exception when the return value is false? |
@@ -424,7 +431,7 @@ DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { |
msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); |
uint8_t* data = NULL; |
- MessageWriter writer(&data, &allocator, false); |
+ MessageWriter writer(&data, &malloc_allocator, &malloc_deallocator, false); |
writer.WriteMessage(msg); |
PortMap::PostMessage(new Message(port.Id(), data, writer.BytesWritten(), |