I need a head check...
I'm creating a new database record, inserting the new record in the
correct sort position. However, this is in a Beam receive function, so
its possible that the record add can be aborted. I'm doing something
like this:
newRecordHandle = DmNewHandle (db, bytesToRead); // new unattached
record for DB
newRecordPtr = MemHandleLock(newRecordHandle);
// NOT SHOWN: read record from Beam, DmWrite() data into record
handle...
// NOTE: there could be an error in which case *err is non-zero
// clean up if an error occurred
if (*err) {
MemHandleUnlock(newRecordHandle);
MemHandleFree(newRecordHandle); // toss handle
}
else {
index = DmFindSortPosition(db, newRecordPtr, 0, (DmComparF *)
CompareFunc, 0);
DmAttachRecord (db, &index, (Handle) newRecordHandle, NULL);
MemHandleUnlock(newRecordHandle);
DmReleaseRecord(db, index, true);
}
This *seems* to work correctly, in that if *err is non-zero the
MemHandleFree() executes without error. I'm just wondering if its
*legal*. The docs, even the new 3.1 docs, are unclear on this point.
It's sure a lot cleaner than allocating a record, deleting it if there's
an error, and sorting the database when you're done.
Thanks!
--
John Schettino - http://members.tripod.com/schettino/
CORBA For Dummies, AppleScript Applications, and more.