Actually, I'm pretty sure the problem isn't the StrCopy() statement 
itself (the argument about the "\0" is a red herring), but the memory 
handling instead.

boo[100];

StrCopy(boo,"blah");

is a common construction, but in the memory limited environment of 
Palm OS probably too sloppy -- there's no way to guarantee that the 
stack has the 100 bytes available when you ask for it, and since 
dynamic memory is pretty small, there a good chance that it won't.

This is the whole reason the PalmOS offers locked chunks.  This 
guarantees a safe piece of memory for manipulation.  In my 
experience, the only route to truly reliable code in PalmOS is to 
explicitly allocate every byte and explicitly deallocate it when 
you're done.  It's a pain in the butt, but I find it oddly satisfying 
to watch my program not leak any memory at all...

Hence:

VoidHand        h;
CharPtr         c;

h=MemHandleNew(pick_your_size);
c=MemHandleLock(h);

StrCopy(c,"blah blah blah");

MemHandleUnlock(h);
MemHandleFree(h);

will a) solve your problem and b)lead to longer but more explicit and 
safe code.
-- 
------------------------------------------------------------------------------
Michael Hutchens                        PregCalc, Ranson, FloChart
[EMAIL PROTECTED]                         http://www.thenar.com

Please quote previous correspondence when discussing technical support issues.


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