Root > Reference > All Functions > MemLeaksOwn

Procedure MemLeaksOwn

Previous pageReturn to chapter overviewNext page   

Sets ownership for memory block.

 

Unit

EMemLeaks

 

Syntax

 

Code (Delphi)

procedure MemLeaksOwn(

const AParentBlock, AChildBlock: Pointer;

const AName: String = ''

);

 

Parameters

AParentBlock [in]

A pointer to parent block.

 

AChildBlock [in]

A pointer to child block.

 

AName [in, optional]

A custom name for the AChildBlock block. Empty string (default) means "do not change name".

 

Remarks

This function is a combination of MemLeaksSetParentBlock and MemLeaksName functions. MemLeaksOwn will name AChildBlock with AName (as MemLeaksName do) and sets AParentBlock as a parent to AChildBlock (as MemLeaksSetParentBlock do).

 

The difference is that MemLeaksOwn will not overwrite a parent link in AChildBlock if that link was already set. Whereas MemLeaksSetParentBlock will always set parent link. This difference allows you to use MemLeaksOwn to set ownership for reference-counted data types passed to you as arguments. For example, if string is passed to constructor of your object, and you save this string into field of your object - you may use MemLeaksOwnStr to claim ownership of this string.

 

Important!

You must pass a pointer to the beginning of the memory block. Please note that dynamic arrays and strings do not point to the beginning of allocation. Use MemLeaksOwnDynArrayChild, MemLeaksOwnDynArrayParent, MemLeaksOwnDynArrayBoth and MemLeaksOwnStr for dynamic arrays and strings instead of this function.

 

See also




Send feedback... Build date: 2024-09-30
Last edited: 2024-09-30
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_ememleaks_memleaksown.php