(Sorry if this has been covered, but I didn't see anyting in the archive. )

I have a data structure declared for my App, with mostly Char*'s as members:

typedef structure {
        bool mybool;
        char* one;
        char* two;
        char*   three;
} MyStruct;

I use the structure to pass info around the application. A few minutes ago, I
was thinking and realized that I had made a mistake, but now I've just confused
myself. 

Say one function gets a memory chunk using MemHandleNew, copies a string into
it, and points MyStruct->one at it. Repeat the process for two and three all in
the following manner:

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?

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?

TIA, hope it's not too stupid of a question, first Palm App.

Steve Cochran


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to