Page 1 of 1

malloc function?

PostPosted: Sat Jan 30, 2010 8:00 am
by linjichao
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...???????????

Re: malloc function?

PostPosted: Sat Jan 30, 2010 4:32 pm
by makslane
Sorry, array element attribute is not working (array[i]=n).

Re: malloc function?

PostPosted: Mon Feb 01, 2010 1:04 am
by linjichao
makslane wrote:Sorry, array element attribute is not working (array[i]=n).

how can i do?that's have any way to resolve the problem?

Re: malloc function?

PostPosted: Mon Feb 01, 2010 3:43 pm
by makslane
I think only changing the engine code.