>Subject: RE: Freeing memory after reallocation..
>From: "James Nicholls" <[EMAIL PROTECTED]>
>Date: Tue, 10 Jul 2001 15:35:23 +1000
>
>You'll get an error if ID and/or Note are ever assigned string constants and
>you subsequently call MemPtrFree on them. How about never assigning string
>constants to these.
>
>I was about to suggest the PalmOS equivalent of strdup to initialise ID and
>Note from the constants; but there isn't one, only StrCopy. So if you use
>(untested):
>
>Char* StrDup(Char* source)
>{
>       MemPtr p = MemPtrNew(StrLen(source));
>
>       StrCopy((Char*)p, source);
>       return p;
>}

OOPS>>>  MemPtr p = MemPtrNew(StrLen(source));

SHOULD BE>> MemPtr p = MemPtrNew(StrLen(source) + 1);

Roger Stringer
Marietta Systems, Inc.


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