malloc function?

Game Editor comments and discussion.

malloc function?

Postby linjichao » 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...???????????
linjichao
 
Posts: 35
Joined: Fri Jan 22, 2010 10:13 am
Score: 0 Give a positive score

Re: malloc function?

Postby makslane » Sat Jan 30, 2010 4:32 pm

Sorry, array element attribute is not working (array[i]=n).
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: malloc function?

Postby linjichao » Mon Feb 01, 2010 1:04 am

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?
linjichao
 
Posts: 35
Joined: Fri Jan 22, 2010 10:13 am
Score: 0 Give a positive score

Re: malloc function?

Postby makslane » Mon Feb 01, 2010 3:43 pm

I think only changing the engine code.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron