From b4e1c7d7373bade8cbe522e5b62884ed21f24e57 Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Tue, 11 Mar 2025 09:09:18 -0700 Subject: [PATCH] any: rename `free()` to `freeValue()` Many C++ projects that have their own memory management systems. This is especially the case for games (which often have their own scripting system, which would like to make use of a DAP library to debug them). Often times these games will redefine `free` via a macro to invoke their own memory mangement functions. If `free()` gets defined as a macro, attempting to compile `any.h` will cause the compiler to explode. I note that this is a private function that is only used within `any.h` and it's only used twice, so this should not create any API compatibility issues. --- include/dap/any.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/dap/any.h b/include/dap/any.h index b05f03d..e799c44 100644 --- a/include/dap/any.h +++ b/include/dap/any.h @@ -67,7 +67,7 @@ class any { static inline void* alignUp(void* val, size_t alignment); inline void alloc(size_t size, size_t align); - inline void free(); + inline void freeValue(); inline bool isInBuffer(void* ptr) const; void* value = nullptr; @@ -106,7 +106,7 @@ any::any(any&& other) noexcept : type(other.type) { void any::reset() { if (value != nullptr) { type->destruct(value); - free(); + freeValue(); } value = nullptr; type = nullptr; @@ -191,7 +191,7 @@ void any::alloc(size_t size, size_t align) { value = alignUp(heap, align); } -void any::free() { +void any::freeValue() { assert(value != nullptr); if (heap != nullptr) { delete[] reinterpret_cast(heap);