| Index: src/value-serializer.h
|
| diff --git a/src/value-serializer.h b/src/value-serializer.h
|
| index bb483dd7c874f066a971127beecc3533df4e52e9..86e21cf86cbf1eedfb4a94535fe1b8ce93865c95 100644
|
| --- a/src/value-serializer.h
|
| +++ b/src/value-serializer.h
|
| @@ -59,7 +59,13 @@ class ValueSerializer {
|
| * Returns the stored data. This serializer should not be used once the buffer
|
| * is released. The contents are undefined if a previous write has failed.
|
| */
|
| - std::vector<uint8_t> ReleaseBuffer() { return std::move(buffer_); }
|
| + std::vector<uint8_t> ReleaseBuffer();
|
| +
|
| + /*
|
| + * Returns the buffer, allocated via the delegate, and its size.
|
| + * Caller assumes ownership of the buffer.
|
| + */
|
| + std::pair<uint8_t*, size_t> Release();
|
|
|
| /*
|
| * Marks an ArrayBuffer as havings its contents transferred out of band.
|
| @@ -79,6 +85,9 @@ class ValueSerializer {
|
| void WriteDouble(double value);
|
|
|
| private:
|
| + // Managing allocations of the internal buffer.
|
| + void ExpandBuffer(size_t required_capacity);
|
| +
|
| // Writing the wire format.
|
| void WriteTag(SerializationTag tag);
|
| template <typename T>
|
| @@ -126,7 +135,9 @@ class ValueSerializer {
|
|
|
| Isolate* const isolate_;
|
| v8::ValueSerializer::Delegate* const delegate_;
|
| - std::vector<uint8_t> buffer_;
|
| + uint8_t* buffer_ = nullptr;
|
| + size_t buffer_size_ = 0;
|
| + size_t buffer_capacity_ = 0;
|
| Zone zone_;
|
|
|
| // To avoid extra lookups in the identity map, ID+1 is actually stored in the
|
|
|