hv reddy wrote:
> In SampleLib I really didn't understand where they are using 
> Global(pseudo)variables.

I thought the SampleLib code made it pretty clear.  IIRC, it has functions 
called PrvNewGlobals to allocate globals (which it calls from its Open() 
function) and PrvGetGlobals to retrieve them.  I might be remembering the names 
incorrectly.

> If you don't mind can you please little elaborate the 
> explanation .
> Means As your example in LibOpen
> libEntryP->globalsP = globaltest;
> After that we need not to assign Any memory for the structure?

Huh?  Look at the code I wrote again.  Memory was allocated for the structure 
with MemPtrNew, and the pointer to that structure is stored in 
libEntryP->globalsP.

Now, I didn't do anything to *initialize* the values of that structure.  It's 
your responsibility to do what you want with it.

> Can we use this globaltest variable in other part of library 
> as a normal global variable ?

No, that's the whole point.  You cannot use globally-scoped variables.  If you 
want to have global-like data that persists between functions in your library, 
you need to store that data in a known location (in this case, the library's 
table entry, which you get by calling SysLibTblEntry(libRefNum)).

Please look at the SampleLib code.

- James
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to