fixed fp issue again, and then change vsprintf for something

This commit is contained in:
qeed 2010-10-01 19:27:12 +00:00
parent b7b3319dfc
commit fc1a10b2a4
2 changed files with 14 additions and 6 deletions

View File

@ -133,12 +133,20 @@ public:
va_list argptr;
va_start(argptr, format);
char *tempbuf = new char[size()];
int amt;
amt = vsnprintf(tempbuf, size(), format, argptr);
char *placeholder = new char[20];
placeholder[0] = 20;
//we dont generate straight into the buffer because it will null terminate (one more byte than we want)
int amt = vsnprintf(0,0,format,argptr);
/*int amt = vsnprintf(0,0,format,argptr);
char* tempbuf = new char[amt+1];
vsprintf(tempbuf,format,argptr);
vsprintf(tempbuf,format,argptr);*/
fwrite(tempbuf,amt);
delete[] tempbuf;
delete[] placeholder;
va_end(argptr);
return amt;
};

View File

@ -474,7 +474,7 @@ void FCEUSS_Save(const char *fname)
st = FCEUD_UTF8_fstream(fn,"wb");
}
if(st == NULL)
if(st == NULL || st->get_fp() == NULL)
{
FCEU_DispMessage("State %d save error.",0,CurrentState);
return;