Lumiera
0.pre.03
»edit your freedom«
|
This situation typically arises when some plain-C function returns results in a heap allocated buffer, requiring the client to care for proper clean-up. To avoid creating a liability, we wrap the buffer into a smart pointer, which acts as ownership token and abstracts the specifics of clean-up.
This test places a given (or random) string into a heap malloced buffer, and then pushes the "hot potato" of ownership responsibility around; another function checks the content of the buffer and consumes the token as a side-effect. At the end, there should be no memory leak and the ownership token should be empty.
Definition at line 68 of file unique-malloc-owner-test.cpp.
Private Types | |
using | CharOwner = UniqueMallocOwner< char > |
Private Member Functions | |
CharOwner | place_into_malloced_buffer (string probeString) |
virtual void | run (Arg args) |
void | verify_and_consume (CharOwner hotPotato, string refString) |