diff --git a/libraries/libstratosphere/include/stratosphere/ams/ams_environment.hpp b/libraries/libstratosphere/include/stratosphere/ams/ams_environment.hpp
index c237ed05f..13f20a5d5 100644
--- a/libraries/libstratosphere/include/stratosphere/ams/ams_environment.hpp
+++ b/libraries/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/libraries/libstratosphere/include/stratosphere/rapidjson.hpp b/libraries/libstratosphere/include/stratosphere/rapidjson.hpp
index 9a68b1674..fafc93671 100644
--- a/libraries/libstratosphere/include/stratosphere/rapidjson.hpp
+++ b/libraries/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/libraries/libstratosphere/source/ams/ams_environment_weak.cpp b/libraries/libstratosphere/source/ams/ams_environment_weak.cpp
index a4c36a6a8..89b68067a 100644
--- a/libraries/libstratosphere/source/ams/ams_environment_weak.cpp
+++ b/libraries/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" {
diff --git a/stratosphere/htc/source/htc_main.cpp b/stratosphere/htc/source/htc_main.cpp
index 775dff411..e9797aca1 100644
--- a/stratosphere/htc/source/htc_main.cpp
+++ b/stratosphere/htc/source/htc_main.cpp
@@ -110,6 +110,21 @@ namespace ams {
AMS_ABORT("ams::Free was called");
}
+ void *MallocForRapidJson(size_t size) {
+ AMS_ABORT("ams::MallocForRapidJson was called");
+ }
+
+ void *ReallocForRapidJson(void *ptr, size_t size) {
+ AMS_ABORT("ams::ReallocForRapidJson was called");
+ }
+
+ void FreeForRapidJson(void *ptr) {
+ if (ptr == nullptr) {
+ return;
+ }
+ AMS_ABORT("ams::FreeForRapidJson was called");
+ }
+
}
void *operator new(size_t size) {