Skip to content
Myr

stb_leakcheck: add support for output to stderr

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Dima Krasner · committed by Dima Krasner · parent bcb2815 · Browse files · 1 file+8 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−4 removed

  • other:+8 added−4 removed

1 file+8 added−4 removed

modified:stb_leakcheck.h+8 added-4 removed
11 unmodified lines
12#undef free13#undef realloc14#endif1516#ifndef STB_LEAKCHECK_OUTPUT_PIPE17#define STB_LEAKCHECK_OUTPUT_PIPE stdout18#endif1920#include <assert.h>21#include <string.h>22#include <stdlib.h>23#include <stdio.h>
76 unmodified lines
100 // and the older ones don't even have %lld either... however, the old compilers101 // without "long long" don't support 64-bit targets either, so here's the102 // compromise:103 #if _MSC_VER < 1400 // before VS 2005100 printf("%s: %s (%4d): %8d bytes at %p\n", reason, mi->file, mi->line, (int)mi->size, (void*)(mi+1));104 fprintf(STB_LEAKCHECK_OUTPUT_PIPE, "%s: %s (%4d): %8d bytes at %p\n", reason, mi->file, mi->line, (int)mi->size, (void*)(mi+1));105 #else102 printf("%s: %s (%4d): %16lld bytes at %p\n", reason, mi->file, mi->line, (long long)mi->size, (void*)(mi+1));106 fprintf(STB_LEAKCHECK_OUTPUT_PIPE, "%s: %s (%4d): %16lld bytes at %p\n", reason, mi->file, mi->line, (long long)mi->size, (void*)(mi+1));107 #endif108#else109 // Assume we have %zd on other targets.110 #ifdef __MINGW32__107 __mingw_printf("%s: %s (%4d): %zd bytes at %p\n", reason, mi->file, mi->line, mi->size, (void*)(mi+1));111 __mingw_fprintf(STB_LEAKCHECK_OUTPUT_PIPE, "%s: %s (%4d): %zd bytes at %p\n", reason, mi->file, mi->line, mi->size, (void*)(mi+1));112 #else109 printf("%s: %s (%4d): %zd bytes at %p\n", reason, mi->file, mi->line, mi->size, (void*)(mi+1));113 fprintf(STB_LEAKCHECK_OUTPUT_PIPE, "%s: %s (%4d): %zd bytes at %p\n", reason, mi->file, mi->line, mi->size, (void*)(mi+1));114 #endif115#endif116}117
77 unmodified lines