Sack Library Documentation
ContentsIndexReferenceHome
PreviousUpNext
sack::memory::HoldEx Function
C++
MEM_PROC POINTER MEM_API HoldEx(POINTER pData DBG_PASS);
#define Hold(p) HoldEx(p DBG_SRC )
Parameters 
Description 
pointer 
pointer to a block of memory that was Allocate()'d. 

Adds a usage count to a block of memory. For each count added, an additional release must be used. This can be used to keep a copy of the block, even if some other code automatically releases it.

Allocate a block of memory, and release it properly. But we passed it to some function. That function wanted to keep a copy of the block, so it can apply a hold. It needs to later do a Release again to actually free the memory.

POINTER p = Allocate( 32 );
   
call_some_function( p );
   
Release( p );
   
   
void call_some_function( POINTER p )
{
   static POINTER my_p_copy;
   my_p_copy = p;
   Hold( p );
}
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.
Copyright (c) 2000+. All rights reserved.
What do you think about this topic? Send feedback!