Sack Library Documentation
ContentsIndexReferenceHome
PreviousUpNext
sack::app::registry::RegisterAndCreateGlobalWithInit Function
C++
IMPORT_METHOD void CPROC RegisterAndCreateGlobalWithInit(POINTER * ppGlobal, PTRSZVAL global_size, CTEXTSTR name, void (__cdecl*Init)(POINTER,PTRSZVAL));
#define SimpleRegisterAndCreateGlobalWithInit( name,init ) RegisterAndCreateGlobalWithInit( (POINTER*)&name, sizeof( *name ), WIDE(#name), init )
Parameters 
Description 
POINTER * ppGlobal 
Address of the pointer to the global region 
PTRSZVAL global_size 
size of the global region to create 
CTEXTSTR name 
name of the global region to register (so future users get back the same data area) 
Init 
function to call to initialize the region when created. (doesn't have to be a global. Could be used to implement types that have class constructors - or not, since there's only one instance of a global - this is more for singletons). 

Init routine is called, otherwise a 0 filled space is returned. Init routine is passed the pointer to the global and the size of the global block the global data block is zero initialized.

typedef struct {
   int data;
} my_global;
my_global *global;
   
void __cdecl InitRegion( POINTER region, PTRSZVAL region_size )
{
    // do something to initialize 'region'
}
   
PRELOAD( InitGlobal )
{
    SimpleRegisterAndCreateGlobalWithInit( global, InitRegion );
}
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!