I have library function that gives memory leackage problem for the pointer ( unsigned char * pBuffer ) see below mentioned code .
unsigned char* CCFileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize)
{
unsigned char * pBuffer = NULL;
unzFile pFile = NULL;
**pSize = 0;
do
{
CC_BREAK_IF;
CC_BREAK_IF 0);
pFile = unzOpen(pszZipFilePath);
CC\_BREAK\_IF(!pFile);
int nRet = unzLocateFile(pFile, pszFileName, 1);
CC\_BREAK\_IF(UNZ\_OK != nRet);
char szFilePathA[260];
unz\_file\_info FileInfo;
nRet = unzGetCurrentFileInfo(pFile, &FileInfo, szFilePathA, sizeof(szFilePathA), NULL, 0, NULL, 0);
CC\_BREAK\_IF(UNZ\_OK != nRet);
nRet = unzOpenCurrentFile(pFile);
CC\_BREAK\_IF(UNZ\_OK != nRet);
pBuffer = new unsigned char[FileInfo.uncompressed\_size];
int nSize = 0;
nSize = unzReadCurrentFile(pFile, pBuffer, FileInfo.uncompressed\_size);
CCAssert(nSize 0 || nSize == FileInfo.uncompressed\_size, “the file size is wrong”);
**pSize = FileInfo.uncompressed_size;
unzCloseCurrentFile(pFile);
} while (0);
if (pFile)
{
unzClose(pFile);
}
return pBuffer;
}