malloc function?
Posted: Sat Jan 30, 2010 8:00 am
ppContent = (char**)malloc((*lineInt_count)*sizeof(char)*4);
ppInt_content = (int**)ppContent; // get current head of address
// each line num store into correspond buffer
for(i = 0; i < (*lineInt_count); i++)
{
char ss[50];
memset(ss, '\0', 50);
readFileLine(file, ss, NULL);
ss[strlen(ss)] = '\0';
(*ppContent) = (char*)malloc(strlen(ss)*sizeof(char)+1); // error ? in vs2005 by win32 console,is OK. but it can't run in game script
strcpy(*ppContent, ss);
(*ppContent)[strlen(ss)] = '\0';
sprintf(file_text.text, "current content is: %s", *ppContent);
ppInt_content++;
ppContent = (char**)ppInt_content;
}
error: write attempted beyond allow access area...???????????
ppInt_content = (int**)ppContent; // get current head of address
// each line num store into correspond buffer
for(i = 0; i < (*lineInt_count); i++)
{
char ss[50];
memset(ss, '\0', 50);
readFileLine(file, ss, NULL);
ss[strlen(ss)] = '\0';
(*ppContent) = (char*)malloc(strlen(ss)*sizeof(char)+1); // error ? in vs2005 by win32 console,is OK. but it can't run in game script
strcpy(*ppContent, ss);
(*ppContent)[strlen(ss)] = '\0';
sprintf(file_text.text, "current content is: %s", *ppContent);
ppInt_content++;
ppContent = (char**)ppInt_content;
}
error: write attempted beyond allow access area...???????????