From 85a7f32e494a2e42b726ff232efe5abc2587eb31 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Sun, 29 Apr 2012 23:21:34 +0000 Subject: [PATCH] -updated sd card debug log writer, now should work fine if wiiflow is on usb too --- source/gecko/gecko.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/gecko/gecko.c b/source/gecko/gecko.c index 2c472b6c..33151e42 100644 --- a/source/gecko/gecko.c +++ b/source/gecko/gecko.c @@ -1,6 +1,8 @@ //Enable the line below to always write SD log //#define sd_write_log +#define filebuffer 1024 + #include #include #include @@ -71,14 +73,14 @@ void WriteToFile(char* tmp) { if(bufferMessages) { - if(strlen(tmpfilebuffer) + strlen(tmp) <= 1024) + if((strlen(tmpfilebuffer) + strlen(tmp)) < filebuffer) strcat(tmpfilebuffer, tmp); } else { if(tmpfilebuffer != NULL) { - free(tmpfilebuffer); + SAFE_FREE(tmpfilebuffer); tmpfilebuffer = NULL; } return; @@ -90,7 +92,7 @@ void WriteToFile(char* tmp) if(outfile) { fwrite(tmpfilebuffer, 1, strlen(tmpfilebuffer), outfile); - memset(tmpfilebuffer, 0, strlen(tmpfilebuffer)); + memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer)); fclose(outfile); } } @@ -149,7 +151,8 @@ bool InitGecko() USBGeckoOutput(); - tmpfilebuffer = (char*)malloc(sizeof(char[1024])); + tmpfilebuffer = (char*)calloc(filebuffer + 1, sizeof(char)); + #ifdef sd_write_log WriteToSD = true; #endif