bwidiger wrote: > > I have insert your part of code in the code from Harsha. > After compiling and linking with CodeWarrior 9.2 (they show > no errors) the sample crashs. > If I comment the line > > libEntryP->globalsP = globaltest; > > the sample run well. > What is wrong?
Is libEntryP initialized? Did you get it from SysLibTblEntry(libRefNum)? Without seeing your code, I have no idea. How did it crash? > Does you need to dealloc the memory with MemPtrFree(globaltest)? Yes. If you allocated that memory with MemPtrNew, then you must free it with MemPtrFree. > If yes, where is the correct place? In the end of > ECLibOpen-function or in the ECLibClose-function? How you manage your memory is up to you. The system makes no requirements. That said, if you allocate memory in your library's Open() function, then if Open() succeeds, you should free in its Close() function. (If you freed your globals at the end of Open(), how would other functions in your library use them?) If Open() fails, however, you should make sure it cleans up after itself. And make sure you handle the case of nested Open() calls to your library. > How can I used the location (table entry) in other function in > same library and in sub-libraries (called from this library with > globaltest)? I don't understand what you mean. Please, please, look at the SampleLib code that PalmSource provides. I can't stress this enough. It shows you how to allocate and free memory. It shows you how other library functions can access it. There are also open-source Palm OS shared libraries that you can look at too. (For example, MathLib, MDLib, SHALib, etc.) - James -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
