Issue #597 - Add WIN CRT memory debug in tidy.c

This commit is contained in:
Geoff McLane 2017-09-17 16:27:17 +02:00
parent 98eb7b20ba
commit 3e27882109

View file

@ -27,6 +27,10 @@
#endif
#if !defined(NDEBUG) && defined(_MSC_VER)
#include "sprtf.h"
#ifdef _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
#endif
#ifndef SPRTF
@ -1882,7 +1886,7 @@ int main( int argc, char** argv )
{
ctmbstr prog = argv[0];
ctmbstr cfgfil = NULL, errfil = NULL, htmlfil = NULL;
TidyDoc tdoc = tidyCreate();
TidyDoc tdoc = NULL;
int status = 0;
tmbstr locale = NULL;
@ -1890,6 +1894,16 @@ int main( int argc, char** argv )
uint contentWarnings = 0;
uint accessWarnings = 0;
#if !defined(NDEBUG) && defined(_MSC_VER)
#if defined(_CRTDBG_MAP_ALLOC)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
set_log_file((char *)"temptidy.txt", 0);
/* add_append_log(1); */
#endif
tdoc = tidyCreate();
tidySetMessageCallback( tdoc, reportCallback); /* experimental group */
errout = stderr; /* initialize to stderr */
@ -1914,12 +1928,6 @@ int main( int argc, char** argv )
SetConsoleOutputCP(CP_UTF8);
#endif
#if !defined(NDEBUG) && defined(_MSC_VER)
set_log_file((char *)"temptidy.txt", 0);
/* add_append_log(1); */
#endif
/*
* Look for default configuration files using any of
* the following possibilities: