Hi,
> typedef structure {
> bool mybool;
> char* one;
> char* two;
> char* three;
> } MyStruct;
What I suggest here is that it would be better to declare your strings as
arrays rather than pointers. If you use pointers, you must make sure that
your strings are still valid at that pointer location when you want to use
them. If you use arrays, you could simply use MemMove to copy the string
contents into your struct.
> MyStruct struct = MemHandleNew(sizeof(MyStruct));
> Char* src = "test";
> MemHandle tmpH = MemHandleNew(StrLen(s)+1);
> s = MemHandleLock(tmpH);
> struct->one = s;
> MemHandleUnlock(tmpH);
>
> I then pass the struct onto another function. Those char* in the struct
won't be
> valid, since I didn't keep the Handles locked after setting the Char* to
point
> at the string, correct?
Yup.
> If this is the case, is it better to use MemHandles in the struct instead
of
> char*'s? What's the 'normal' way to handle this?
Well, you could. But that would make things more complicated right? You'll
need to lock down the handle when you want to use the string, and you'll
need to free the handle when your strings are no longer in use. I think it's
better to declare them as char arrays. :)
> TIA, hope it's not too stupid of a question, first Palm App.
We all have our first. :)
Regards,
Gee.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/