Actually, i just wanna test out what happen if I first initialised the
handle to size 1 then resize it in hexdump() and perform the StrCopy.... I
thought this will return value that has been copied but Gees... it doesn't
and return an empty string instead...
I absolutely agree with you. but since I'm using Char* pointer which point
to the memhandle , any modification on the Char* in hexdump() should be
reflected in myTest() as well.... but it doesn't... :)) funny ...
The reason i pass both the Char* and MemHandle is to enable me to resize it
in hexdump .... for experimental purpose...
thanx
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf
> Of Richard
> Burmeister
>>
> > From: Tan Kuan Eeik
> >
> > the thing is I don't understand that :
> >
> > 1. when we initialize the phandle in myTest() ,
> > phtxt(hextxt)="" is pointing to 0x25ec.
> > 2. when we resize phandle in hexdump(),
> > hextxt(phtxt)="12 34" is pointing to 0x2e00.
>
> When you unlock a handle and resize it, the memory block is
> likely to move
> (especially if you make it bigger!). That's the whole
> purpose of Handles --
> to provide a means to allocate and use moveable memory
> blocks. When you
> lock a handle, you get a pointer to the memory and then you
> can access it.
> When it is unlocked, the Memory Manager can move it around to
> make room for
> memory allocation.
>
> > hexdump(Char* stxt, Char* hextxt, MemHandle phandle)
> > {
> > ...........
> > MemHandleUnlock(phandle);
> > MemHandleResize(phandle, 3*StrLen(slen+1));
> > hextxt = (Char*) MemHandleLock(phandle); -->phtxt is
> > allocated at 0x2e00
> > StrCopy(hextxt, htxt);
> > ........
> > }
>
> I don't understand why you are passing in both the pointer
> (hextxt) and the
> handle (phandle). Just use one. If you pass in the pointer,
> the memory it
> points to is locked and you can use StrCopy() to copy your
> string. This
> requires you to pass in a pointer to a string that is big
> enough to hold the
> text you want to copy. If you pass in the handle, it should
> be unlocked
> when you pass it in, then you can resize it, lock it to get a
> pointer, copy
> text to the string, and finally unlock it.
>
>
> --
> For information on using the Palm Developer Forums, or to
> unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/