From: "Sam Trimble" <[EMAIL PROTECTED]>
Subject: Garbage CharPtr


>  I have a global CharPtr being used a whole lot and the length of it can
get
> from 35 to 350 chars long. But whenever I change any other variables in my
> code it gets cut off and I get garbage in it. Is there some way to keep
> other things from interfereing w/ my string?

Assuming you actually allocated space for 350 chars for the CharPtr, it
sounds suspiciously like the problem is with how you are changing the other
variables.  Are you properly allocating space for the other variables?

Your global CharPtr should be declared like this:

Char gSomeString[350];    // declares gSomeString and allocates 350 bytes
for it

then you can use it anywhere in your program.

Or, alternatively, declare it like this:

Char * gSomeString;

// then to use it ...
gSomeString = MemPtrNew(350);    // allocate space
if (gSomeString)
{
    // use the string
}

// then to free up the memory when you're done using it ...
MemPtrFree(gSomeString);

Do the same thing with all the CharPtrs you use.



-- 
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