Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi,

I'm reading images from a directory and using - IMENUCTL_GetSel(),IMENUCTL_GetItem() to get the ID of the currently selected item.
I'm releasing all the interfaces created but the application fails to free memory,.I have debugged my application and found that all the data is getting freed until the the funtion "menu_query()" is called.

I want to know, does the reference count increase in some way by using IMENUCTL_GetSel(),IMENUCTL_GetItem() ,. Below is a snippet of my code

static void menu_query(ifotofx* pMe){

CtlAddItem *ai;
uint16 itemid;
int i=0;
boolean b;
char* pszDest;
ai = MALLOC(sizeof(CtlAddItem));
itemid = IMENUCTL_GetSel(pMe->m_pMenu);
ai->wItemID = itemid;
b= IMENUCTL_GetItem(pMe->m_pMenu,itemid,ai);

pszDest = MALLOC(sizeof(byte)*((MAX_FILE_NAME+1)/2));
WSTRTOSTR(ai->pText,pszDest,(MAX_FILE_NAME+1)/2) ;
pMe->name1 = MALLOC(((MAX_FILE_NAME+1)/2) * sizeof(char));
STRCPY(pMe->name1, pszDest);
FREEIF(ai);
FREEIF(pszDest);

Thanks,..
Smita

PS - I'm displaying just file names and no thumnails

Do you ever free the memory you allocated for pMe->name1? Otherwise, you'll have a memory leak every time you call this function.

Do you ever free the memory you allocated for pMe->name1? Otherwise, you'll have a memory leak every time you call this function.

Hi Mohlendo,
Thanks for the reply.
I'm freeing pMe->name1 in "FreeAppData" function. The menu items are created using IFileMgr followed by "MenuCtl_AddItem()" ,. Does "IMenuctl_GetSel , IMenuCtl_GetItem" allocate memory internally when getting the details of currently selected item? (I'm not using thumbnails so no IImage interface is created)..Also checked the reference count of IMenuCtl in the FreeAppData function ,it is decrementing to 0,.
Also,is there any chance of memory leak when moving back and forth between screens..
Thanks
Smita

Hi Mohlendo,
Thanks for the reply.
I'm freeing pMe->name1 in "FreeAppData" function. The menu items are created using IFileMgr followed by "MenuCtl_AddItem()" ,. Does "IMenuctl_GetSel , IMenuCtl_GetItem" allocate memory internally when getting the details of currently selected item? (I'm not using thumbnails so no IImage interface is created)..Also checked the reference count of IMenuCtl in the FreeAppData function ,it is decrementing to 0,.
Also,is there any chance of memory leak when moving back and forth between screens..
Thanks
Smita

Hi Mohlendo,.
You were right ,. It was pMe->name1 that created the problem..Now my code's working fine ,.Thanks!!

Hi Mohlendo,.
You were right ,. It was pMe->name1 that created the problem..Now my code's working fine ,.Thanks!!

hi
in menu items i have my friends list,say a
b
c
now i want to pic item which ever is selected through menu,so that i can append it (name of friend)for the request to the server.
i used IMENUCTL_GetSel api to get the selected itme id.
now how can i use this id to retrieve the name of friend.
i thought IMENUCTL_GetItem will help but it only returns boolean type so????
no idea.
with regards
Ashutosh

hi
in menu items i have my friends list,say a
b
c
now i want to pic item which ever is selected through menu,so that i can append it (name of friend)for the request to the server.
i used IMENUCTL_GetSel api to get the selected itme id.
now how can i use this id to retrieve the name of friend.
i thought IMENUCTL_GetItem will help but it only returns boolean type so????
no idea.
with regards
Ashutosh

I actually want to retrieve resource id of my image
ret_item=IMENUCTL_GetSel(pMe->pIMenu_buddy);
if(IMENUCTL_GetItem(pMe->pIMenu_buddy,ret_item,&pai)==TRUE)
{
p=pai.wImage;

This thing is not working for me....can anyone help
regards
Ashutosh

I actually want to retrieve resource id of my image
ret_item=IMENUCTL_GetSel(pMe->pIMenu_buddy);
if(IMENUCTL_GetItem(pMe->pIMenu_buddy,ret_item,&pai)==TRUE)
{
p=pai.wImage;

This thing is not working for me....can anyone help
regards
Ashutosh