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