mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 21:00:17 +02:00
Inheritance can be used here instead, which allows the JsonAllocator to be reconstructed using a downcast.
24 lines
469 B
C++
24 lines
469 B
C++
// SPDX-License-Identifier: MIT
|
|
|
|
#include <FEXCore/fextl/memory.h>
|
|
#include <FEXCore/fextl/list.h>
|
|
|
|
#include <tiny-json.h>
|
|
|
|
namespace FEX::JSON {
|
|
struct JsonAllocator : jsonPool_t {
|
|
fextl::list<json_t> json_objects;
|
|
|
|
JsonAllocator();
|
|
};
|
|
|
|
template<typename T>
|
|
const json_t* CreateJSON(T& Container, JsonAllocator& Allocator) {
|
|
if (Container.empty()) {
|
|
return nullptr;
|
|
}
|
|
|
|
return json_createWithPool(&Container.at(0), &Allocator);
|
|
}
|
|
} // namespace FEX::JSON
|