Click here to Skip to main content
11,437,713 members (40,213 online)

C / C++ / MFC

 
QuestionFree fails with Access violation reading location [modified] Pin
tejaswini_g24-Mar-14 14:31
membertejaswini_g24-Mar-14 14:31 
AnswerRe: Free fails with Access violation reading location Pin
Richard Andrew x6424-Mar-14 14:42
professionalRichard Andrew x6424-Mar-14 14:42 
GeneralRe: Free fails with Access violation reading location Pin
tejaswini_g24-Mar-14 16:01
membertejaswini_g24-Mar-14 16:01 
AnswerRe: Free fails with Access violation reading location Pin
leon de boer24-Mar-14 16:06
memberleon de boer24-Mar-14 16:06 
GeneralRe: Free fails with Access violation reading location Pin
pwasser24-Mar-14 16:25
memberpwasser24-Mar-14 16:25 
GeneralRe: Free fails with Access violation reading location Pin
pwasser24-Mar-14 16:59
memberpwasser24-Mar-14 16:59 
QuestionRe: Free fails with Access violation reading location [modified] Pin
pwasser24-Mar-14 16:17
memberpwasser24-Mar-14 16:17 
AnswerRe: Free fails with Access violation reading location Pin
tejaswini_g24-Mar-14 16:39
membertejaswini_g24-Mar-14 16:39 
I am posting compiled code. As stated above Freelist[i] fails. Highlighted the statement causing error.

#include <<windows.h>> // remove extra angle bracket for compilation
#include <<tchar.h>>
#include <<stdio.h>>
#include <<strsafe.h>>

void FreeMemory(char** myArray, int row);
void FileCountInDir(const TCHAR* dirpath, int * filescount, int* filesize);
void FindFilesInDirectory(const TCHAR* dirpath, char** filelist);

int _tmain(int argc, TCHAR *argv[])
{
int i =0;
TCHAR szDirpath[MAX_PATH];
//TCHAR Filelist[100][MAX_PATH];
char ** Filelist;
int iFileCountInFolder=0;
int iFileSize = 0;

_tcscpy(szDirpath,_T("C:\\BMPread_W\\TransitionEffects\\Images"));

FileCountInDir(szDirpath,&iFileCountInFolder,&iFileSize);
Filelist = (char**)malloc(iFileCountInFolder * sizeof(char *));
if(Filelist == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
for(i = 0; i < iFileCountInFolder; i++)
{
Filelist[i] = (char*)malloc((iFileSize * sizeof(char))+1);
if(Filelist[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return 0;
}
}
FindFilesInDirectory(szDirpath, Filelist);

for(i =0;i 0)|| ((*filesize) < _tcslen(ffd.cFileName)))
{
(*filesize) = _tcslen(ffd.cFileName);
}
}
}
while (FindNextFile(hFind, &ffd) != 0);
FindClose(hFind);
}

void FreeMemory(char** myArray, int row)
{
int i;
if(myArray != NULL)
{
for (i = 0; i < row; i++){
free (myArray[i]);

}
}
AnswerRe: Free fails with Access violation reading location Pin
pwasser24-Mar-14 17:01
memberpwasser24-Mar-14 17:01 
GeneralRe: Free fails with Access violation reading location Pin
tejaswini_g24-Mar-14 17:11
membertejaswini_g24-Mar-14 17:11 
QuestionHow do you define flags? Pin
Dusan Paulovic24-Mar-14 10:48
memberDusan Paulovic24-Mar-14 10:48 
AnswerRe: How do you define flags? Pin
Richard MacCutchan24-Mar-14 12:11
protectorRichard MacCutchan24-Mar-14 12:11 
AnswerRe: How do you define flags? Pin
Albert Holguin25-Mar-14 5:48
professionalAlbert Holguin25-Mar-14 5:48 
QuestionHow do I using WH_CALLWNDPROC and PT_TOUCH to get the global touch event Pin
cedricvictor24-Mar-14 4:48
membercedricvictor24-Mar-14 4:48 
Questionvisual studio 6.0 Enterprise edition License Pin
KrishnaRayalu_Talisetti24-Mar-14 1:47
memberKrishnaRayalu_Talisetti24-Mar-14 1:47 
AnswerRe: visual studio 6.0 Enterprise edition License Pin
Jochen Arndt24-Mar-14 2:02
professionalJochen Arndt24-Mar-14 2:02 
AnswerRe: visual studio 6.0 Enterprise edition License Pin
DavidCrow24-Mar-14 5:51
memberDavidCrow24-Mar-14 5:51 
QuestionBuilding / compiling DirectShow "empty DLL". Pin
Vaclav_Sal23-Mar-14 6:51
memberVaclav_Sal23-Mar-14 6:51 
SuggestionRe: Building / compiling DirectShow "empty DLL". Pin
Richard MacCutchan23-Mar-14 23:59
protectorRichard MacCutchan23-Mar-14 23:59 
QuestionWin CE program, SetFong() not work Pin
econy21-Mar-14 8:21
memberecony21-Mar-14 8:21 
AnswerRe: Win CE program, SetFong() not work Pin
Rage25-Mar-14 3:15
professionalRage25-Mar-14 3:15 
AnswerRe: Win CE program, SetFong() not work Pin
Rage25-Mar-14 3:17
professionalRage25-Mar-14 3:17 
GeneralRe: Win CE program, SetFong() not work Pin
econy25-Mar-14 4:32
memberecony25-Mar-14 4:32 
QuestionWidth of dropdown list window Pin
bokideclan21-Mar-14 3:33
memberbokideclan21-Mar-14 3:33 
QuestionVery weird change font problem Pin
econy20-Mar-14 9:18
memberecony20-Mar-14 9:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150506.1 | Last Updated 5 May 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid