> Can someone explain this code to me. Its taken from the MailLookup.c
>
> /* some code */
>
> params.formatStringP = MemHandleLock (DmGetResource (strRsc,
> mailLookupFormatStrID));
>
> /* some code */
>
> MemPtrUnlock (params.formatStringP);
>
>
> Why do they lock the handle, but unlock the pointer. Why not call
> MemHandleUnlock?
>
Because MemHandleUnlock ends up calling MemPtrUnlock. Given that they
called DmGetResource, and didn't save it in a handle, they'd have to either
save it in a local variable:
h = DmGetResource(...);
params.formatStringP = MemHandleLock(h);
...
MemHandleUnlock(h);
Or, they'd have to call DmGetResource again.
Since MemHandleUnlock calls MemPtrUnlock, MemPtrUnlock is marginally faster
(I believe Bob Ebert has recommended calling it for that reason).
OTOH, my choice is to always call MemHandleUnlock, since I find it easier to
verify my MemHandleLocks have a matching MemHandleUnlock while perusing my
code.
Neil
--
Neil Rhodes
Calliope Enterprises, Inc.
1328 Clock Avenue
Redlands, CA 92374
(909) 793-5995 [EMAIL PROTECTED] fax: (909) 793-2545