Commit 1e8d963f authored by Anna Henningsen's avatar Anna Henningsen Committed by Commit Bot

[api] Slightly improve ValueSerializer documentation

Without specifying what the default allocator does, using
the buffer returned from `Release()` means that one basically
had to make an educated guess on how to free it
(and that ownership actually was transferred to the caller).

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ie2ac0c91d9bdafbe91f6bce9b2263e304b2336ea
Reviewed-on: https://chromium-review.googlesource.com/1056369Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53225}
parent 9df3c322
...@@ -2025,12 +2025,16 @@ class V8_EXPORT ValueSerializer { ...@@ -2025,12 +2025,16 @@ class V8_EXPORT ValueSerializer {
* If the memory cannot be allocated, nullptr should be returned. * If the memory cannot be allocated, nullptr should be returned.
* |actual_size| will be ignored. It is assumed that |old_buffer| is still * |actual_size| will be ignored. It is assumed that |old_buffer| is still
* valid in this case and has not been modified. * valid in this case and has not been modified.
*
* The default implementation uses the stdlib's `realloc()` function.
*/ */
virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
size_t* actual_size); size_t* actual_size);
/** /**
* Frees a buffer allocated with |ReallocateBufferMemory|. * Frees a buffer allocated with |ReallocateBufferMemory|.
*
* The default implementation uses the stdlib's `free()` function.
*/ */
virtual void FreeBufferMemory(void* buffer); virtual void FreeBufferMemory(void* buffer);
}; };
...@@ -2058,9 +2062,9 @@ class V8_EXPORT ValueSerializer { ...@@ -2058,9 +2062,9 @@ class V8_EXPORT ValueSerializer {
/** /**
* Returns the stored data (allocated using the delegate's * Returns the stored data (allocated using the delegate's
* AllocateBufferMemory) and its size. This serializer should not be used once * ReallocateBufferMemory) and its size. This serializer should not be used
* the buffer is released. The contents are undefined if a previous write has * once the buffer is released. The contents are undefined if a previous write
* failed. * has failed. Ownership of the buffer is transferred to the caller.
*/ */
V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release(); V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment