From 759fbe77e55a260d7b0da045e619fb444f09e77d Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Sun, 2 Aug 2015 22:03:30 +0200 Subject: [PATCH] C++ bindings needed to use system_allocator's free() too --- src/bindings/cpp/hammer/hammer.hpp | 3 ++- src/internal.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bindings/cpp/hammer/hammer.hpp b/src/bindings/cpp/hammer/hammer.hpp index b9de6716..f3939ab3 100644 --- a/src/bindings/cpp/hammer/hammer.hpp +++ b/src/bindings/cpp/hammer/hammer.hpp @@ -2,6 +2,7 @@ #define HAMMER_HAMMER__HPP #include "../../../hammer.h" +#include "../../../internal.h" #include <string> #include <stdint.h> #include <cstdarg> @@ -49,7 +50,7 @@ namespace hammer { std::string asUnambiguous() { char* buf = h_write_result_unamb(token); std::string s = std::string(buf); - free(buf); + (&system_allocator)->free(&system_allocator, buf); return s; } }; diff --git a/src/internal.h b/src/internal.h index 092c158c..ed1bd085 100644 --- a/src/internal.h +++ b/src/internal.h @@ -28,6 +28,11 @@ #include <string.h> #include "hammer.h" +/* "Internal" in this case means "we're not ready to commit + * to a public API." Many structures and routines here will be + * useful in client programs. + */ + #ifdef NDEBUG #define assert_message(check, message) do { } while(0) #else -- GitLab