Fix: leaks and semantics, testing for memory leaks #64
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.
Writing some leak-checking found a few bugs and correctness issues.
sz_string_init_from
would sometimes leave a residue of noise in thespace
field of the new string. Lightly refactor to share some of the logic so it is easier to see that all four fields are set for both shapes of string.The copied code in move constructor and assignment shared some issues: the target for the move didn't actually get initialized with the values of the source. For the case of move assignment where the target already held values, we need to release the associated memory.
I'm happy with the test code for this; while this is probably not a complete inventory of memory leaks, we have an easy way to add tests for new ones we encounter.