-updated sd card debug log writer, now should work fine

if wiiflow is on usb too
This commit is contained in:
fix94.1 2012-04-29 23:21:34 +00:00
parent 61d8ae8c69
commit 85a7f32e49

View File

@ -1,6 +1,8 @@
//Enable the line below to always write SD log //Enable the line below to always write SD log
//#define sd_write_log //#define sd_write_log
#define filebuffer 1024
#include <gccore.h> #include <gccore.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
@ -71,14 +73,14 @@ void WriteToFile(char* tmp)
{ {
if(bufferMessages) if(bufferMessages)
{ {
if(strlen(tmpfilebuffer) + strlen(tmp) <= 1024) if((strlen(tmpfilebuffer) + strlen(tmp)) < filebuffer)
strcat(tmpfilebuffer, tmp); strcat(tmpfilebuffer, tmp);
} }
else else
{ {
if(tmpfilebuffer != NULL) if(tmpfilebuffer != NULL)
{ {
free(tmpfilebuffer); SAFE_FREE(tmpfilebuffer);
tmpfilebuffer = NULL; tmpfilebuffer = NULL;
} }
return; return;
@ -90,7 +92,7 @@ void WriteToFile(char* tmp)
if(outfile) if(outfile)
{ {
fwrite(tmpfilebuffer, 1, strlen(tmpfilebuffer), outfile); fwrite(tmpfilebuffer, 1, strlen(tmpfilebuffer), outfile);
memset(tmpfilebuffer, 0, strlen(tmpfilebuffer)); memset(tmpfilebuffer, 0, sizeof(tmpfilebuffer));
fclose(outfile); fclose(outfile);
} }
} }
@ -149,7 +151,8 @@ bool InitGecko()
USBGeckoOutput(); USBGeckoOutput();
tmpfilebuffer = (char*)malloc(sizeof(char[1024])); tmpfilebuffer = (char*)calloc(filebuffer + 1, sizeof(char));
#ifdef sd_write_log #ifdef sd_write_log
WriteToSD = true; WriteToSD = true;
#endif #endif