From e787f5f43ae0136003606ad0276d68def3c76437 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Fri, 23 Aug 2019 16:33:43 +0300 Subject: [test runner] Overload global new/delete --- render-test/main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/render-test/main.cpp b/render-test/main.cpp index ef9352d21d..46447f5853 100644 --- a/render-test/main.cpp +++ b/render-test/main.cpp @@ -1,3 +1,5 @@ +#include "allocation_index.hpp" + #include #include @@ -19,6 +21,21 @@ #define ANSI_COLOR_LIGHT_GRAY "\x1b[90m" #define ANSI_COLOR_RESET "\x1b[0m" +void* operator new(std::size_t sz) { + void* ptr = AllocationIndex::allocate(sz); + if (!ptr) throw std::bad_alloc{}; + + return ptr; +} + +void operator delete(void* ptr) noexcept { + AllocationIndex::deallocate(ptr); +} + +void operator delete(void* ptr, size_t) noexcept { + AllocationIndex::deallocate(ptr); +} + namespace { TestPaths makeTestPaths(mbgl::filesystem::path stylePath) { -- cgit v1.2.1