Added VS crtdbg memory leak tracking

This commit is contained in:
Wouter van Oortmerssen 2017-08-11 12:24:33 -07:00
parent ffddbdc7ab
commit d5f5d382eb
2 changed files with 38 additions and 16 deletions

View File

@ -1,20 +1,33 @@
#ifndef FLATBUFFERS_BASE_H_
#define FLATBUFFERS_BASE_H_
#if defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#endif
#include <assert.h>
#ifndef ARDUINO
#include <cstdint>
#endif
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <string>
#if defined(_MSC_VER) && defined(_DEBUG)
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
#include <utility.h>
#else
#include <utility>
#endif
#include <string>
#include <type_traits>
#include <vector>
#include <set>

View File

@ -1541,6 +1541,8 @@ void UnionVectorTest() {
fbb.Clear();
fbb.Finish(Movie::Pack(fbb, movie_object));
delete movie_object;
auto repacked_movie = GetMovie(fbb.GetBufferPointer());
TestMovie(repacked_movie);
@ -1737,6 +1739,13 @@ void TypeAliasesTest()
}
int main(int /*argc*/, const char * /*argv*/[]) {
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF
// For more thorough checking:
//| _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF
);
#endif
// Run our various test suites:
std::string rawbuf;