Resolved issues when using GCC >= 12 (#41)
Signed-off-by: Nikhil Manglore <nmanglor@amazon.com> Signed-off-by: Nikhil Manglore <nikhilmanglore9@gmail.com> Co-authored-by: Roshan Khatri <117414976+roshkhatri@users.noreply.github.com>
This commit is contained in:
parent
10d2793bb9
commit
4fb72a9269
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -4,7 +4,7 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-ubuntu-latest:
|
build-ubuntu-latest:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -1432,13 +1432,8 @@ STATIC JValue readLegacyDoubleAsJValue(ValkeyModuleIO *rdb) {
|
|||||||
double d = ValkeyModule_LoadDouble(rdb);
|
double d = ValkeyModule_LoadDouble(rdb);
|
||||||
char str[BUF_SIZE_DOUBLE_JSON];
|
char str[BUF_SIZE_DOUBLE_JSON];
|
||||||
size_t str_len = jsonutil_double_to_string(d, str, sizeof(str));
|
size_t str_len = jsonutil_double_to_string(d, str, sizeof(str));
|
||||||
if (str) {
|
|
||||||
JValue v(str, str_len, allocator, false, /* isdouble */ true);
|
JValue v(str, str_len, allocator, false, /* isdouble */ true);
|
||||||
return v;
|
return v;
|
||||||
} else {
|
|
||||||
ValkeyModule_LogIOError(rdb, "error", "Unable to read legacy double");
|
|
||||||
return JValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -95,18 +95,40 @@ namespace jsn
|
|||||||
//
|
//
|
||||||
// Our custom allocator
|
// Our custom allocator
|
||||||
//
|
//
|
||||||
template <typename T> class stl_allocator : public std::allocator<T> {
|
template <typename T> class stl_allocator {
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
using value_type = T;
|
||||||
stl_allocator() = default;
|
stl_allocator() = default;
|
||||||
stl_allocator(std::allocator<T>&) {}
|
stl_allocator(const stl_allocator<T>&) noexcept = default;
|
||||||
stl_allocator(std::allocator<T>&&) {}
|
stl_allocator(stl_allocator<T>&&) noexcept = default;
|
||||||
template <class U> constexpr stl_allocator(const stl_allocator<U>&) noexcept {}
|
template <class U>
|
||||||
|
constexpr stl_allocator(const stl_allocator<U>&) noexcept {}
|
||||||
|
|
||||||
T *allocate(std::size_t n) { return static_cast<T *>(memory_alloc(n*sizeof(T))); }
|
T* allocate(std::size_t n) {
|
||||||
void deallocate(T *p, std::size_t n) { (void)n; memory_free(p); }
|
return static_cast<T*>(memory_alloc(n * sizeof(T)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate(T* p, std::size_t n) {
|
||||||
|
(void)n;
|
||||||
|
memory_free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void* memory_alloc(std::size_t size) {
|
||||||
|
return std::malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void memory_free(void* p) {
|
||||||
|
std::free(p);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator==(const stl_allocator<T>&, const stl_allocator<U>&) { return true; }
|
||||||
|
|
||||||
|
template <typename T, typename U>
|
||||||
|
bool operator!=(const stl_allocator<T>&, const stl_allocator<U>&) { return false; }
|
||||||
|
|
||||||
template<class Elm> using vector = std::vector<Elm, stl_allocator<Elm>>;
|
template<class Elm> using vector = std::vector<Elm, stl_allocator<Elm>>;
|
||||||
|
|
||||||
template<class Key, class Compare = std::less<Key>> using set = std::set<Key, Compare, stl_allocator<Key>>;
|
template<class Key, class Compare = std::less<Key>> using set = std::set<Key, Compare, stl_allocator<Key>>;
|
||||||
|
@ -2512,7 +2512,7 @@ private:
|
|||||||
DoReserveMembersVec(count, allocator);
|
DoReserveMembersVec(count, allocator);
|
||||||
const typename GenericValue<Encoding,SourceAllocator>::Member* rm = rhs.GetMembersPointerVec();
|
const typename GenericValue<Encoding,SourceAllocator>::Member* rm = rhs.GetMembersPointerVec();
|
||||||
for (SizeType i = 0; i < count; i++) {
|
for (SizeType i = 0; i < count; i++) {
|
||||||
KeyTable_Handle name = std::move(keyTable->clone(rm[i].name));
|
KeyTable_Handle name = keyTable->clone(rm[i].name);
|
||||||
GenericValue value(rm[i].value, allocator, copyConstStrings);
|
GenericValue value(rm[i].value, allocator, copyConstStrings);
|
||||||
DoAddMember(name, value, allocator);
|
DoAddMember(name, value, allocator);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user