Memory leak in STURDUP | developer.brewmp.com Memory leak in STURDUP | developer.brewmp.com

Developer

Memory leak in STURDUP

Forums:

hi there in my app at the end of applet i am receiving module failed to receive all memory

debug report says
:

[HTML]App_Close (10101010) - RESUME
#*gCL=269488144
WARNING: Timer Pending 004F9524
WARNING: App Callback Pending (00C50F00)
App_Cleanup(10101010)
** CLIENTAPP Released
Validating Heap...
------ App Heap Info ------
50 - CLIENTAPP #345 File: clientapp.c Line: 518 (L)
-------------------------
32114 Alloc - Total[/HTML]

now it shows that i have a leak in line number 518
theis line is
// Free the old pointer and fill with STRDUP(pszNew)
//
static void StrReplace(char **ppsz, const char *pszNew)
{
FREE(*ppsz); // FREE(NULL) is okay in BREW
*ppsz = (pszNew ? STRDUP(pszNew) : (char*)pszNew);
// FREE(*ppsz); // FREE(NULL) is okay in BREW

}
please tell whats wrong
thanx
rajat

This code is ok, but your applet should release memory allocated by STRDUP before terminating.

This code is ok, but your applet should release memory allocated by STRDUP before terminating.

STRDUP allocates memory from heap, so it is the responsiblity of application to release that memory.

STRDUP allocates memory from heap, so it is the responsiblity of application to release that memory.

As the name of the function suggestes, it is DUPLICATING the string. A duplicate takes memory... and therefore you will have to release it.

As the name of the function suggestes, it is DUPLICATING the string. A duplicate takes memory... and therefore you will have to release it.