diff --git a/libstratosphere/include/stratosphere/ams/ams_environment.hpp b/libstratosphere/include/stratosphere/ams/ams_environment.hpp index c237ed05..13f20a5d 100644 --- a/libstratosphere/include/stratosphere/ams/ams_environment.hpp +++ b/libstratosphere/include/stratosphere/ams/ams_environment.hpp @@ -29,4 +29,8 @@ namespace ams { void *Malloc(size_t size); void Free(void *ptr); + void *MallocForRapidJson(size_t size); + void *ReallocForRapidJson(void *ptr, size_t size); + void FreeForRapidJson(void *ptr); + } diff --git a/libstratosphere/include/stratosphere/rapidjson.hpp b/libstratosphere/include/stratosphere/rapidjson.hpp index 9a68b167..fafc9367 100644 --- a/libstratosphere/include/stratosphere/rapidjson.hpp +++ b/libstratosphere/include/stratosphere/rapidjson.hpp @@ -14,8 +14,15 @@ * along with this program. If not, see . */ #pragma once +#include +#include -#define RAPIDJSON_NAMESPACE ams::rapidjson +#define RAPIDJSON_NAMESPACE ams::rapidjson +#define RAPIDJSON_ASSERT(x) AMS_ABORT_UNLESS(x) + +#define RAPIDJSON_MALLOC(size) ams::MallocForRapidJson(size) +#define RAPIDJSON_REALLOC(ptr, size) ams::ReallocForRapidJson(ptr, size) +#define RAPIDJSON_FREE(ptr) ams::FreeForRapidJson(ptr) #include #include diff --git a/libstratosphere/source/ams/ams_environment_weak.cpp b/libstratosphere/source/ams/ams_environment_weak.cpp index a4c36a6a..89b68067 100644 --- a/libstratosphere/source/ams/ams_environment_weak.cpp +++ b/libstratosphere/source/ams/ams_environment_weak.cpp @@ -25,6 +25,18 @@ namespace ams { return std::free(ptr); } + WEAK_SYMBOL void *MallocForRapidJson(size_t size) { + return std::malloc(size); + } + + WEAK_SYMBOL void *ReallocForRapidJson(void *ptr, size_t size) { + return std::realloc(ptr, size); + } + + WEAK_SYMBOL void FreeForRapidJson(void *ptr) { + return std::free(ptr); + } + } extern "C" {