Added VS crtdbg memory leak tracking
This commit is contained in:
parent
ffddbdc7ab
commit
d5f5d382eb
|
@ -1,20 +1,33 @@
|
||||||
#ifndef FLATBUFFERS_BASE_H_
|
#ifndef FLATBUFFERS_BASE_H_
|
||||||
#define FLATBUFFERS_BASE_H_
|
#define FLATBUFFERS_BASE_H_
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
|
#define _CRTDBG_MAP_ALLOC
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifndef ARDUINO
|
#ifndef ARDUINO
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
|
||||||
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
|
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
#include <utility.h>
|
#include <crtdbg.h>
|
||||||
#else
|
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||||
#include <utility>
|
#define new DEBUG_NEW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO) && !defined(ARDUINOSTL_M_H)
|
||||||
|
#include <utility.h>
|
||||||
|
#else
|
||||||
|
#include <utility>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -122,8 +135,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4127) // C4127: conditional expression is constant
|
#pragma warning(disable: 4127) // C4127: conditional expression is constant
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// @endcond
|
/// @endcond
|
||||||
|
|
|
@ -1541,6 +1541,8 @@ void UnionVectorTest() {
|
||||||
fbb.Clear();
|
fbb.Clear();
|
||||||
fbb.Finish(Movie::Pack(fbb, movie_object));
|
fbb.Finish(Movie::Pack(fbb, movie_object));
|
||||||
|
|
||||||
|
delete movie_object;
|
||||||
|
|
||||||
auto repacked_movie = GetMovie(fbb.GetBufferPointer());
|
auto repacked_movie = GetMovie(fbb.GetBufferPointer());
|
||||||
|
|
||||||
TestMovie(repacked_movie);
|
TestMovie(repacked_movie);
|
||||||
|
@ -1737,15 +1739,22 @@ void TypeAliasesTest()
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int /*argc*/, const char * /*argv*/[]) {
|
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:
|
// Run our various test suites:
|
||||||
|
|
||||||
std::string rawbuf;
|
std::string rawbuf;
|
||||||
auto flatbuf1 = CreateFlatBufferTest(rawbuf);
|
auto flatbuf1 = CreateFlatBufferTest(rawbuf);
|
||||||
#if !defined(FLATBUFFERS_CPP98_STL)
|
#if !defined(FLATBUFFERS_CPP98_STL)
|
||||||
auto flatbuf = std::move(flatbuf1); // Test move assignment.
|
auto flatbuf = std::move(flatbuf1); // Test move assignment.
|
||||||
#else
|
#else
|
||||||
auto &flatbuf = flatbuf1;
|
auto &flatbuf = flatbuf1;
|
||||||
#endif // !defined(FLATBUFFERS_CPP98_STL)
|
#endif // !defined(FLATBUFFERS_CPP98_STL)
|
||||||
AccessFlatBufferTest(reinterpret_cast<const uint8_t *>(rawbuf.c_str()),
|
AccessFlatBufferTest(reinterpret_cast<const uint8_t *>(rawbuf.c_str()),
|
||||||
rawbuf.length());
|
rawbuf.length());
|
||||||
AccessFlatBufferTest(flatbuf.data(), flatbuf.size());
|
AccessFlatBufferTest(flatbuf.data(), flatbuf.size());
|
||||||
|
@ -1761,10 +1770,10 @@ int main(int /*argc*/, const char * /*argv*/[]) {
|
||||||
test_data_path = FLATBUFFERS_STRING(FLATBUFFERS_TEST_PATH_PREFIX) +
|
test_data_path = FLATBUFFERS_STRING(FLATBUFFERS_TEST_PATH_PREFIX) +
|
||||||
test_data_path;
|
test_data_path;
|
||||||
#endif
|
#endif
|
||||||
ParseAndGenerateTextTest();
|
ParseAndGenerateTextTest();
|
||||||
ReflectionTest(flatbuf.data(), flatbuf.size());
|
ReflectionTest(flatbuf.data(), flatbuf.size());
|
||||||
ParseProtoTest();
|
ParseProtoTest();
|
||||||
UnionVectorTest();
|
UnionVectorTest();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FuzzTest1();
|
FuzzTest1();
|
||||||
|
|
Loading…
Reference in New Issue