Chromium Code Reviews| Index: runtime/vm/dart_api_message.h |
| diff --git a/runtime/vm/dart_api_message.h b/runtime/vm/dart_api_message.h |
| index 70d55f9eb75d39a7a58816fde1c4d417f4564125..cd4f0048b919691fec8524408f2e2bad0d3cc9cd 100644 |
| --- a/runtime/vm/dart_api_message.h |
| +++ b/runtime/vm/dart_api_message.h |
| @@ -41,14 +41,10 @@ struct Dart_CObject_Internal : public Dart_CObject { |
| // Reads a message snapshot into a C structure. |
| class ApiMessageReader : public BaseReader { |
| public: |
| - // The allocator passed is used to allocate memory for the C structure used |
| - // to represent the message snapshot. This allocator must keep track of the |
| - // memory allocated as there is no way to run through the resulting C |
| - // structure and free the individual pieces. Using a zone based allocator is |
| - // recommended. |
| - ApiMessageReader(const uint8_t* buffer, |
| - intptr_t length, |
| - ReAlloc alloc); |
| + // The ApiMessageReader object must be enclosed by an ApiNativeScope. |
| + // Allocation of all C Heap objects is done in the zone associated with |
| + // the enclosing ApiNativeScope. |
| + ApiMessageReader(const uint8_t* buffer, intptr_t length); |
| ~ApiMessageReader() { } |
| Dart_CObject* ReadMessage(); |
| @@ -139,10 +135,11 @@ class ApiMessageReader : public BaseReader { |
| Dart_CObject* GetCanonicalMintObject(Dart_CObject_Type type, |
| int64_t value64); |
| - // Allocation of the structures for the decoded message happens |
| - // either in the supplied zone or using the supplied allocation |
| - // function. |
| - ReAlloc alloc_; |
| + uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
|
Cutch
2015/08/25 20:57:52
We always pass NULL in as ptr. This interface coul
siva
2015/08/25 21:28:19
Done.
|
| + return zone_->Realloc<uint8_t>(ptr, old_size, new_size); |
| + } |
| + |
| + Zone* zone_; // Zone in which C heap objects are allocated. |
| ApiGrowableArray<BackRefNode*> backward_references_; |
| ApiGrowableArray<Dart_CObject*> vm_isolate_references_; |
| Dart_CObject** vm_symbol_references_; |