Am Donnerstag, 10. Juni 2004 12:35 schrieb Ste: > Hi all, > I have a doubt about MemHandleFree... have I to call this function > everytime, after I unlock a chunk with MemHandleUnlock? or if i don't call > it, the system use the chunk when it needs it? > > For istance, every sample i've found with DmQueryRecord doesn't call > MemHandleFree, but why? Here is a sample from CodeWarrior documentation.... > > MemHandle h = DmQueryRecord( dbRef, index ); > MyRecord *rec = (MyRecord *) MemHandleLock( h ); > . . . . . // do something here > MemHandleUnlock( h ); > > Why doesn't it call MemHandleFree at the end?
Because you don't want to free the chunk. The data should remain in the database, so it must not be freed. If you create a handle with MemHandleNew, you have to free it with MemHandleFree when you don't need it anymore. You need MemHandleLock and MemHandleUnlock when you want to actually _use_ the data; you need MemHandleNew and MemHandleFree to create and destroy a memory chunk. -- Greetings Helmut A. Bender Helmut Bender GmbH -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
