change pointer returned by Serialize() to be smart #601
+46
−37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
@adamdempsey90 pointed out that
Serialize()is a bit unsafe as it returns a pointer that then must be managed by the host code. This is subtle also because, depending on how an EOS is deserialized, that pointer may need to stick around for the lifetime of the EOS.To make things a bit safer, I make
Serialize()return a smart pointer and add some additional documentation. I note that I am a little torn on this as this is the only place in the code that smart pointers are used. So I worry that it may create a pattern with an exception... i.e., you always must manage your memory except for this one case.Nevertheless it is a bit cleaner.
PR Checklist
make formatcommand after configuring withcmake.If preparing for a new release, in addition please check the following: