WARNING: NEWBIE to C! I am porting my programs from VB to C and C++. With my current program, I have a timer that calls the following function (IsFulll()) which calls the GetRecentDocs() function...
Code:
char *GetRecentDocs() {
LPITEMIDLIST pidl;
if (SHGetSpecialFolderLocation(NULL, CSIDL_RECENT, &pidl) == NOERROR) {
/* char buffer = new char[MAX_PATH]; Causes Mem Leak */
/* static char buffer[MAX_PATH]; Causes Mem Leak */
char buffer[MAX_PATH] = ""; /* Compiler Local Variable Error and Mem Leak */
SHGetPathFromIDList(pidl, buffer);
return buffer;
}
}
int IsFull() {
char *sPath;
sPath = GetRecentDocs();
/* sPath = "C:\\Documents and Settings\\chris\\Recent\\*.lnk"; Hard Coded causes no Mem Leaks */
strcat(sPath, "\\*.lnk");
HANDLE hFile = 0;
WIN32_FIND_DATA wfs;
hFile = FindFirstFile(sPath, &wfs);
if (strstr(wfs.cFileName, ".lnk") != NULL) {
return 1;
} else {
return 0;
}
}
As noted, my problem is with memory leaks. Mem Usage in the Task manager increases between 4 and 8 bytes. Left the program for an hour and it got up to 17Mb. Any ideas would be greatly appreciated...