Hi there Im confused by the whole handle issue, iirc if I call MemHandleNew I should latter call MemHandleFree when im not going to need that movable chunk anymore. is this correct?
There are some functions that return a handle like DmNewRecord but
when I naively tryied to call MemHandleFree over those i have gotten
a bunch of resets due to memmory management issues, is it that i _just_
have to call MemHandleFree when Im done with a chunk I have explicitly
asked for with MemHandleNew?
On another side of the same topic, there is a paragraph on the sdk docs
that goes like this about MemHandleLock:
"Call this routine to lock a chunk and obtain a pointer to the chunk.
MemHandleLock and MemHandleUnlock should be used in pairs."
An If you take a look at this code, extracted from palmsource/Access
knowledge base...
static void CreateRecord()
{
MemHandle h;
UInt16 index = 0;
DBRecordType r; // this is our database record
h = DmNewRecord(gDatabase, &index, sizeof(r));
// fill the record with data
StrCopy(r.FirstName, "Jun");
StrCopy(r.LastName, "Zhou");
StrCopy(r.PhoneNum, "1 555 545 4434");
if (h) { // could fail due to
insufficient memory!
MemPtr p = MemHandleLock(h);
Err err = DmWrite(p,
0, &r, sizeof(r));
MemPtrUnlock(p);
DmReleaseRecord(gDatabase,
index,
true);
}
}
Reviewing MemPrtUnlock documentation leads me to believe his function
is analogous to that of MemHandleUnlock but, is there some _:rule:_
to choose one over the other when i have access to the handle AND the
pointer ? like in the sample above? (Anyway, someone shoud fix that doc entry
asking for strict MemHandleock/MemHandleUnlock pairs ..)
Hope you an understand my weird english.
Reynaldo
signature.asc
Description: Digital signature
