Durgesh,
Well it's *OBVIOUSLY* because of ItemType = (Char**)MemPtrNew(dbCount *
sizeof(Char*));
You're freeing it, and then immediately allocating it again.
You could use something like the code I originally suggested where you
call the function again with a zero parameter to tidy up.
Or you could make ItemType a global, and free it on exit from your app.

Or, if you are already calling this function twice - once to set up and
once to clear, but for some reason are not able to call the function
with a zero parameter, you could rewrite the function as follows.

static void TodayAppList(FormType* frm) { 
SysDBListItemType          *dbListIDsP; 
MemHandle                  dbListIDsH; 
static UInt16              dbCount = 0; 
UInt16 counter; 
Boolean                    status;                 
ListType*  lst;
static char **ItemType; 
 
UInt16 ListItemNum;
   // item = MemPtrNew(20);
        //MemSet(item,20,'\0');
     if(ItemType)
       {
                 for(counter=0;counter<dbCount;counter++)
                        {
                                MemPtrFree(ItemType[counter]);
                        }
                        MemPtrFree(ItemType);
                        dbCount=0;
                }
else
{                          
           status = SysCreateDataBaseList(sysFileTApplication,
0,&dbCount, &dbListIDsH,true); 
           ItemType = (Char**)MemPtrNew(dbCount * sizeof(Char*)); 
      
            dbListIDsP = (SysDBListItemType*)MemHandleLock (dbListIDsH);

     if (status == true && dbCount > 0)   
       { 
        for (counter = 0; counter < dbCount; counter++) 
          {              
                   ItemType[counter] =
(Char*)MemPtrNew(dmDBNameLength+1);                
                        StrCopy(ItemType[counter],
dbListIDsP[counter].name);

          }  
          
                    lst =
(ListType*)FrmGetObjectPtr(frm,FrmGetObjectIndex(frm, TodayPrefList));

            LstSetListChoices (lst,ItemType,dbCount);           
            ListItemNum= LstGetSelection (lst);             
            item= LstGetSelectionText(lst,ListItemNum);            
                                
            MemHandleUnlock(dbListIDsH);            
           MemPtrFree(dbListIDsP); 
               
      }
}
  }

Regards
John Sutton

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Durgesh
Trivedi
Sent: 13 September 2006 11:42
To: Palm Developer Forum
Subject: RE: List draw error

here is my code 4 the list it is give memoy  lick error when exit the
application static void TodayAppList(FormType* frm) { 
SysDBListItemType          *dbListIDsP; 
MemHandle                  dbListIDsH; 
static UInt16              dbCount = 0; 
UInt16 counter; 
Boolean                    status;                 
ListType*  lst;
static char **ItemType; 
 
UInt16 ListItemNum;
   // item = MemPtrNew(20);
        //MemSet(item,20,'\0');
     if(ItemType)
       {
                 for(counter=0;counter<dbCount;counter++)
                        {
                                MemPtrFree(ItemType[counter]);
                        }
                        MemPtrFree(ItemType);
                        dbCount=0;
                }
                           
           status = SysCreateDataBaseList(sysFileTApplication,
0,&dbCount, &dbListIDsH,true); 
           ItemType = (Char**)MemPtrNew(dbCount * sizeof(Char*)); 
      
            dbListIDsP = (SysDBListItemType*)MemHandleLock (dbListIDsH);

     if (status == true && dbCount > 0)   
       { 
        for (counter = 0; counter < dbCount; counter++) 
          {              
                   ItemType[counter] =
(Char*)MemPtrNew(dmDBNameLength+1);                
                        StrCopy(ItemType[counter],
dbListIDsP[counter].name);

          }  
          
                    lst =
(ListType*)FrmGetObjectPtr(frm,FrmGetObjectIndex(frm, TodayPrefList));

            LstSetListChoices (lst,ItemType,dbCount);           
            ListItemNum= LstGetSelection (lst);             
            item= LstGetSelectionText(lst,ListItemNum);            
                                
            MemHandleUnlock(dbListIDsH);            
           MemPtrFree(dbListIDsP); 
               
      }
  }

and i think it is bcz of  this
 ItemType = (Char**)MemPtrNew(dbCount * sizeof(Char*));
--
For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

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

Reply via email to