Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
UniqueMallocOwner_test Class Reference

Description

Test:
Verify automatic management of memory originally allocated by C malloc. 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.

See also
lib::UniqueMallocOwner
lib::meta::demangleCxx

Definition at line 68 of file unique-malloc-owner-test.cpp.

Private Types

using CharOwner = UniqueMallocOwner< char >
 

Private Member Functions

virtual void run (Arg args)
 
CharOwner place_into_malloced_buffer (string probeString)
 
void verify_and_consume (CharOwner hotPotato, string refString)
 

Member Typedef Documentation

◆ CharOwner

using CharOwner = UniqueMallocOwner<char>
private

Definition at line 71 of file unique-malloc-owner-test.cpp.

Member Function Documentation

◆ run()

virtual void run ( Arg  args)
inlineprivatevirtual

Definition at line 74 of file unique-malloc-owner-test.cpp.

References UniqueMallocOwner_test::place_into_malloced_buffer(), lib::test::randStr(), and UniqueMallocOwner_test::verify_and_consume().

+ Here is the call graph for this function:

◆ place_into_malloced_buffer()

CharOwner place_into_malloced_buffer ( string  probeString)
inlineprivate

Definition at line 86 of file unique-malloc-owner-test.cpp.

Referenced by UniqueMallocOwner_test::run().

+ Here is the caller graph for this function:

◆ verify_and_consume()

void verify_and_consume ( CharOwner  hotPotato,
string  refString 
)
inlineprivate

Definition at line 95 of file unique-malloc-owner-test.cpp.

Referenced by UniqueMallocOwner_test::run().

+ Here is the caller graph for this function:
+ Inheritance diagram for UniqueMallocOwner_test:
+ Collaboration diagram for UniqueMallocOwner_test:

The documentation for this class was generated from the following file: