DetachedBuffer cannot be rewrapped#4885
Conversation
auto dBufferRaw = builder.ReleaseRaw();in #4885 : I tried to have this release functionality discused in #4848 : the problem I stumbled upon is: Second, there is this bool,
Maybe we could in the future remove the Thanks for your help. |
include/flatbuffers/flatbuffers.h
Outdated
| /// case `allocator() == nullptr` (where the DefaultAllocator has been used!). | ||
| /// The user is also responsible to delete the allocator `allocator()` if it | ||
| /// is owned `allocator_owned()`. | ||
| class DetachedBufferRaw { |
There was a problem hiding this comment.
Lets not have yet another class for this. The idea was a simple function that just gives you a raw pointer back, + size/offset
There was a problem hiding this comment.
Also happy with such an approach. without std::tuple. will change it...
|
do you rather prefer a return struct or a return by input arguments? or a I would define a return struct... |
|
I would just keep it super simple, e.g. |
|
:) ok. will adapt to this intention. super simple is ok. super ugly not. will make arg references :). thx |
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
|
CLAs look good, thanks! |
|
Requesting review, for my changes :-) Thanks =) |
include/flatbuffers/flatbuffers.h
Outdated
|
|
||
| // Relinquish the pointer to the caller. | ||
| uint8_t *release_raw(size_t &size, size_t &offset) { | ||
| uint8_t *buf = buf_; |
| size = reserved_; | ||
| offset = static_cast<size_t>(cur_ - buf_); | ||
|
|
||
| if (own_allocator_ && allocator_) { delete allocator_; } |
There was a problem hiding this comment.
maybe put these 3 lines in a clear_allocator and also call it from the destructor?
|
good point
|
include/flatbuffers/flatbuffers.h
Outdated
| } | ||
|
|
||
| void clear_allocator() | ||
| { |
There was a problem hiding this comment.
{ on prev line, same below
There was a problem hiding this comment.
thx, I couldnt somehow use clang-format -> kind of messes up everything, when I apply it... (i use clang 6.0 maybe thats why...
|
|
There is no member |
|
see travis output |
|
Looks good, thanks! |
* Simple ReleaseRaw implemented * [doc] * clear_buffer and clear_allocator introduced * auto * typos * rename because of -Werror=shadow
Pull request for Issue #4848.
Added a DetachedBufferRaw for external rewrapping.