Subject: Re: memory leaks From: "Merav Rubinstein" <[EMAIL PROTECTED]> Date: Sat, 14 Aug 2004 13:10:13 -0000
my code is:
in the handle event, open form:
for(i = 0; i < 50; i++) { statuslist[i]=MemPtrNew(sizeof(Char)*STATUS_LENGH); StrCopy(statuslist[i],""); }
handle event, close form:
for(i = 0; i < MAX_LEN; i++) { if(statuslist[i]) { MemPtrFree(statuslist[i]); statuslist[i] = NULL; } }
I use those strings all the time and when I use the debugger I can see that the MemPtrFree causes the problem , usually when i=40, and sometime it works. Any one has idea?
Why not make the allocation a little larger and see if the problem disappears.
statuslist[i]=MemPtrNew(sizeof(Char)*(STATUS_LENGH + 2));
It is likely you are corrupting the memory pointers somewhere in your program and the most likely source of the corruption is writing a char too many.
Also set the entire allocated memory to 0, not just the first byte, so replace
StrCopy(statuslist[i],"");
with
if (statuslist[i]) MemSet (status[i], STATUS_LENGH + 2, '\0');
Roger Stringer Marietta Systems, Inc. (www.rf-tp.com)
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
