> I'm using the following code to create a string list for a list and when I
> exit the app I'm getting "SystemMgr.c Line:4192, Possible memory
leak....."
> Would anyone let me know what kind of clean up I need to do after doing
> this. Thanks...
>
> Char    CurItem[35];
> CharPtr *AllItems;
> VoidHand txtH;
> Int x = 0;
> Int i = 0;
>
>  for (x = 0; x < NumOfChoices; x++) {
>   StrCopy(CurItem, ReturnSelection(1, x));      ///ReturnSelection is my
own
> function for returning the item that needs to be in that place
>   txtH = MemHandleNew(StrLen(CurItem) + 1);
>   AllItems[i] = MemHandleLock(txtH);
>   StrCopy(AllItems[i], CurItem);
>   i++;
>  }
> LstSetListChoices(List*, AllItems, NumOfChoices);

Where do you allocate AllItems itself? In any event, you need to free it,
together with all the chunks it points to. You do this when you have
finished displaying your list. You might want to add a FrmCloseEvent to your
event loop for this purpose.

But you would be much better off using a callback function to draw the items
in your list. It might seem complicated, but it would save you an awful lot
of hassle, viz:

static void DrawItem(LInt p,
RectanglePtr r, CharPtr *dummy){
 DrawBytes(p, ReturnSelection(1, p), 0, r);
}

 LstSetDrawFunction(List, DrawItem);

And we are done. Here LInt is either Int or UInt, depending on your level of
PalmOS.



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