mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
rapidjson: add customization point for allocation/asserts
This commit is contained in:
parent
2cdfde6637
commit
0977ee72ca
4 changed files with 39 additions and 1 deletions
|
@ -29,4 +29,8 @@ namespace ams {
|
||||||
void *Malloc(size_t size);
|
void *Malloc(size_t size);
|
||||||
void Free(void *ptr);
|
void Free(void *ptr);
|
||||||
|
|
||||||
|
void *MallocForRapidJson(size_t size);
|
||||||
|
void *ReallocForRapidJson(void *ptr, size_t size);
|
||||||
|
void FreeForRapidJson(void *ptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,15 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <vapours.hpp>
|
||||||
|
#include <stratosphere/ams/ams_environment.hpp>
|
||||||
|
|
||||||
#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 <stratosphere/rapidjson/rapidjson.h>
|
#include <stratosphere/rapidjson/rapidjson.h>
|
||||||
#include <stratosphere/rapidjson/encodings.h>
|
#include <stratosphere/rapidjson/encodings.h>
|
||||||
|
|
|
@ -25,6 +25,18 @@ namespace ams {
|
||||||
return std::free(ptr);
|
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" {
|
extern "C" {
|
||||||
|
|
|
@ -110,6 +110,21 @@ namespace ams {
|
||||||
AMS_ABORT("ams::Free was called");
|
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) {
|
void *operator new(size_t size) {
|
||||||
|
|
Loading…
Reference in a new issue