Update to work with new librexy allocators
This commit is contained in:
parent
e77d20cae4
commit
0d226f3148
@ -27,13 +27,16 @@ namespace rjp{
|
||||
namespace detail{
|
||||
struct allocator
|
||||
{
|
||||
static void free(void* data);
|
||||
static void* allocate(size_t size);
|
||||
static void* copy(const void* data, size_t len);
|
||||
using size_type = size_t;
|
||||
using pointer = char*;
|
||||
using const_pointer = const char*;
|
||||
|
||||
char* allocate(size_type n);
|
||||
void deallocate(pointer data, size_type n);
|
||||
};
|
||||
}
|
||||
|
||||
class string : public rexy::string_intermediary<detail::allocator>
|
||||
class string : public rexy::basic_string<detail::allocator>
|
||||
{
|
||||
public:
|
||||
string(const string&) = default;
|
||||
@ -41,9 +44,9 @@ namespace rjp{
|
||||
string& operator=(const string&) = default;
|
||||
string& operator=(string&&) = default;
|
||||
|
||||
using rexy::string_intermediary<detail::allocator>::string_intermediary;
|
||||
using rexy::basic_string<detail::allocator>::basic_string;
|
||||
string(RJP_value* r);
|
||||
using rexy::string_intermediary<detail::allocator>::operator=;
|
||||
using rexy::basic_string<detail::allocator>::operator=;
|
||||
string& operator=(RJP_value* r);
|
||||
};
|
||||
|
||||
|
||||
@ -21,15 +21,10 @@
|
||||
#include <cstring> //memcpy
|
||||
|
||||
namespace rjp::detail{
|
||||
void allocator::free(void* data){
|
||||
void allocator::deallocate(pointer data, size_type){
|
||||
rjp_free(data);
|
||||
}
|
||||
void* allocator::allocate(size_t size){
|
||||
return rjp_alloc(size);
|
||||
}
|
||||
void* allocator::copy(const void* data, size_t len){
|
||||
char* tmp = reinterpret_cast<char*>(allocate(len));
|
||||
memcpy(tmp, data, len);
|
||||
return tmp;
|
||||
auto allocator::allocate(size_type size) -> pointer{
|
||||
return reinterpret_cast<char*>(rjp_alloc(size));
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
namespace rjp{
|
||||
|
||||
string::string(RJP_value* r):
|
||||
rexy::string_intermediary<detail::allocator>(rexy::steal(r ? rjp_get_string(r)->value : nullptr),
|
||||
rexy::basic_string<detail::allocator>(rexy::steal(r ? rjp_get_string(r)->value : nullptr),
|
||||
r ? rjp_get_string(r)->length : 0,
|
||||
r ? rjp_get_string(r)->length : 0)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user