"Steve Jackson" <[EMAIL PROTECTED]> wrote in message
news:12777@palm-dev-forum...
[snip]
>
> This is the sequence you need to use:
> 1. MemHandleNew
> 2. MemHandleLock
> 3. Work with locked chunk until you determine it needs to be enlarged.
> 4. MemHandleUnlock
> 5. MemHandleResize to enlarge it
> 6. MemHandleLock
> 7. Work with enlarged locked chunk.
> 8. MemHandleUnlock
> 9. MemHandleFree
Thanks for the reply, Steve.
I have another couple of questions for the gurus:
I know it's possible to recover the handle from a MemPtr, but is this only
possible to do if the MemPtr was obtained from locking a MemHandle?
i.e. can I go MemPtrNew, then if I need to grow it do MemPtrRecoverHandle,
MemHandleUnlock, MemHandleResize, and then MemHandleLock again to get a
pointer to the increased buffer?
(I'm guessing not, but it's worth a shot)
Secondly, given that you should never rely on being able to increase the
size of buffers obtained from MemPtrNew, how do you recommend going about
programming things like variable length arrays and structs. For instance, in
my code I have a variable length array of structs which contain variable
length strings, which means I need 3 lots of malloc'ing if it was normal C
to do (once for the array, again for each struct, and the third time for
each string). If I am to rewrite this using Handles it looks like a huge
hassle. Any suggestions or advice?
thanks again,
Rhys.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/