Mercurial > repos > rhope
view debugmacros.h @ 121:1af91ceaaf49
Fixed memory leak when an output is only attached to a single null input
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 28 Oct 2010 21:04:12 -0400 |
parents | 76568becd6d6 |
children |
line wrap: on
line source
#ifndef _DEBUGMACROS_H_ #define _DEBUGMACROS_H_ //#define TEXT_FILE_DEBUG 1 #ifdef TEXT_FILE_DEBUG #include <stdio.h> void * debug_malloc(size_t size, char * msg); #define DEBUGPRINTF(format, ...) fprintf(debugfile, format, __VA_ARGS__); fflush(debugfile) #define DEBUGPUTS(string) fputs(string, debugfile); fflush(debugfile) extern FILE * debugfile; #ifdef MALLOC_DEBUG #define MALLOC(size, msg) debug_malloc(size, msg) #define VIS_FREE(ptr, msg) fprintf(debugfile, "free: %X, %s\n", ptr, msg); fflush(debugfile); free(ptr) #else #define MALLOC(size, msg) malloc(size) #define VIS_FREE(ptr, msg) free(ptr) #endif #else #ifdef BOX_DEBUG #define DEBUGPRINTF(format, ...) sprintf(debugbuffer, format, __VA_ARGS__); MessageBox(NULL, debugbuffer, "Debug", MB_OK) #define DEBUGPUTS(string) MessageBox(NULL, string, "Debug", MB_OK) #else #ifdef CONSOLE_DEBUG #include <stdio.h> #define DEBUGPRINTF(format, ...) printf(format, __VA_ARGS__); fflush(stdout); #define DEBUGPUTS(string) fputs(string, stdout); fflush(stdout); #else #define DEBUGPRINTF #define DEBUGPUTS #define MALLOC(size, msg) malloc(size) #define VIS_FREE(ptr, msg) free(ptr) #endif //CONSOLE_DEBUG #endif //BOX_DEBUG #endif //TEXT_FILE_DEBUG #ifdef WIN32 #ifdef GUI_LIB extern char errorbuffer[1024]; #define ERRORPUTS(string) DEBUGPUTS(string); MessageBox(NULL, string, "Rhope Error", MB_OK); #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); sprintf(errorbuffer, format, __VA_ARGS__); MessageBox(NULL, errorbuffer, "Rhope Error", MB_OK); #else #define ERRORPUTS(string) DEBUGPUTS(string); puts(string)/*fputs(string, stderr);*/ #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); printf(format, __VA_ARGS__);/* fprintf(stderr, format, __VA_ARGS__); */ #endif #else #if defined(SEGA) | defined(NINTENDO_DS) #define ERRORPUTS(string) DEBUGPUTS(string); puts(string) #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); printf(format, __VA_ARGS__) #else #define ERRORPUTS(string) DEBUGPUTS(string); fputs(string, stderr) #define ERRORPRINTF(format, ...) DEBUGPRINTF(format, __VA_ARGS__); fprintf(stderr, format, __VA_ARGS__) #endif #endif #endif //_DEBUGMACROS_H_