flush logfile in case of crash

This commit is contained in:
ac-stef
2015-03-25 02:56:49 +01:00
parent 54ed91732e
commit 85f7a22e64
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
void cleanup(char *msg) // single program exit point;
{
if(clientlogfile) clientlogfile->fflush();
if(!msg)
{
cleanupclient();
@@ -29,6 +30,7 @@ VAR(resetcfg, 0, 0, 1);
void quit() // normal exit
{
if(clientlogfile) clientlogfile->fflush();
const char *onquit = getalias("onQuit");
if(onquit && onquit[0]) execute(onquit);
alias("onQuit", "");
@@ -43,7 +45,6 @@ void quit() // normal exit
writeallxmaps();
cleanup(NULL);
popscontext();
extern stream *clientlogfile;
DELETEP(clientlogfile);
exit(EXIT_SUCCESS);
}
+1
View File
@@ -422,6 +422,7 @@ struct filestream : stream
bool end() { return feof(file)!=0; }
long tell() { return ftell(file); }
bool seek(long offset, int whence) { return fseek(file, offset, whence) >= 0; }
void fflush() { if(file) ::fflush(file); }
int read(void *buf, int len) { return (int)fread(buf, 1, len, file); }
int write(const void *buf, int len) { return (int)fwrite(buf, 1, len, file); }
int getchar() { return fgetc(file); }
+3 -2
View File
@@ -14,9 +14,9 @@ typedef unsigned int uint;
#ifdef _DEBUG
#ifdef __GNUC__
#define ASSERT(c) if(!(c)) { asm("int $3"); }
#define ASSERT(c) if(!(c)) { fflush(NULL); asm("int $3"); }
#else
#define ASSERT(c) if(!(c)) { __asm int 3 }
#define ASSERT(c) if(!(c)) { fflush(NULL); { __asm int 3 } }
#endif
#include <iostream>
@@ -914,6 +914,7 @@ struct stream
virtual long tell() { return -1; }
virtual bool seek(long offset, int whence = SEEK_SET) { return false; }
virtual long size();
virtual void fflush() {}
virtual int read(void *buf, int len) { return 0; }
virtual int write(const void *buf, int len) { return 0; }
virtual int getchar() { uchar c; return read(&c, 1) == 1 ? c : -1; }