Am Freitag, 3. September 2004 08:21 schrieb salil khanwalkar:
> Hi,
> I did check what LstNewList returns, it returns me a 0 so its working
> properly. The error is on the LstPopupList() line. I also tried using
> LstDrawList(). It shows memory leaks in the log files.
>
> if (LstNewList((void**)&frmP,1,10,10,50,50,stdFont,3,2) == 0)
> {
>    list = (ListType*)GetObjectPtr((UInt16)1);
>    memList = SysFormPointerArrayToStrings(c,stringCount);
>    memP = (MemPtr*)MemHandleLock(memList);
>    LstSetListChoices(list,(Char**)memList,15);
>    LstPopupList(list);// line where the error occurs 
>    MemPtrUnlock(memP);
> }
>
> Regards,
> Salil.

The LstSetListChoices needs a pointer to an array of char. So you shouldn't 
take memList (which is a MemHandle) but memP. As LstSetListChoices doesn't 
copy the strings, this pointer has to be valid as long as it is used, so 
don't unlock or free memP until you don't need the list any longer.

To avoid memory leaks you should unlock and free memList as soon as you don't 
need the list anymore.

I hope the rest of the variables are correct (e.g. stringCount >= 15).

-- 
Mit freundlichen Gr��en
Helmut A. Bender
Helmut Bender GmbH

--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to