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

@ -132,13 +132,21 @@ public:
virtual int fprintf(const char *format, ...) {
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);
fwrite(tempbuf,amt);
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;
@ -729,7 +729,7 @@ bool FCEUSS_Load(const char *fname)
SaveStateStatus[CurrentState]=0;
return false;
}
//If in bot mode, don't do a backup when loading.
//Otherwise you eat at the hard disk, since so many
//states are being loaded.