Skip to content

Commit

Permalink
Disable MemoryPoolAllocator on ARM to avoid #4839.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mewes committed Oct 5, 2015
1 parent a2033a0 commit 851b2f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/rapidjson/allocators.h
Expand Up @@ -105,6 +105,13 @@ class RAllocator {
\tparam BaseAllocator the allocator type for allocating memory chunks. Default is RAllocator.
\note implements Allocator concept
*/
// RethinkDB patch: The MemoryPoolAllocator doesn't currently work properly on
// ARM. See https://github.com/rethinkdb/rethinkdb/issues/4839
// and https://github.com/miloyip/rapidjson/issues/388 .
#if defined(__arm__)
#define MAYBE_POOL_ALLOCATOR RAllocator
#else
#define MAYBE_POOL_ALLOCATOR MemoryPoolAllocator<>
template <typename BaseAllocator = RAllocator>
class MemoryPoolAllocator {
public:
Expand Down Expand Up @@ -252,6 +259,7 @@ class MemoryPoolAllocator {
BaseAllocator* baseAllocator_; //!< base allocator for allocating memory chunks.
BaseAllocator* ownBaseAllocator_; //!< base allocator created by this object.
};
#endif /* Compiling the MemoryPoolAllocator only if not on ARM */

RAPIDJSON_NAMESPACE_END

Expand Down
4 changes: 2 additions & 2 deletions src/rapidjson/document.h
Expand Up @@ -417,7 +417,7 @@ template <typename T> struct IsGenericValue : IsGenericValueImpl<T>::Type {};
\tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document)
\tparam Allocator Allocator type for allocating memory of object, array and string.
*/
template <typename Encoding, typename Allocator = MemoryPoolAllocator<> >
template <typename Encoding, typename Allocator = MAYBE_POOL_ALLOCATOR >
class GenericValue {
public:
//! Name-value pair in an object.
Expand Down Expand Up @@ -1623,7 +1623,7 @@ typedef GenericValue<UTF8<> > Value;
\tparam StackAllocator Allocator for allocating memory for stack during parsing.
\warning Although GenericDocument inherits from GenericValue, the API does \b not provide any virtual functions, especially no virtual destructor. To avoid memory leaks, do not \c delete a GenericDocument object via a pointer to a GenericValue.
*/
template <typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = RAllocator>
template <typename Encoding, typename Allocator = MAYBE_POOL_ALLOCATOR, typename StackAllocator = RAllocator>
class GenericDocument : public GenericValue<Encoding, Allocator> {
public:
typedef typename Encoding::Ch Ch; //!< Character type derived from Encoding.
Expand Down
8 changes: 4 additions & 4 deletions src/rdb_protocol/term_storage.cc
Expand Up @@ -390,7 +390,7 @@ MUST_USE archive_result_t deserialize_protobuf<Backtrace>(read_stream_t *s,
Backtrace *bt);

rapidjson::Value convert_datum(const Datum &src,
rapidjson::MemoryPoolAllocator<> *allocator) {
rapidjson::MAYBE_POOL_ALLOCATOR *allocator) {
guarantee(src.has_type());
switch (src.type()) {
case Datum::R_NULL:
Expand Down Expand Up @@ -439,10 +439,10 @@ rapidjson::Value convert_datum(const Datum &src,
}

rapidjson::Value convert_term_tree(const Term &src,
rapidjson::MemoryPoolAllocator<> *allocator);
rapidjson::MAYBE_POOL_ALLOCATOR *allocator);

rapidjson::Value convert_optargs(const Term &src,
rapidjson::MemoryPoolAllocator<> *allocator) {
rapidjson::MAYBE_POOL_ALLOCATOR *allocator) {
rapidjson::Value dest(rapidjson::kObjectType);
for (int i = 0; i < src.optargs_size(); ++i) {
const Term_AssocPair &optarg = src.optargs(i);
Expand All @@ -455,7 +455,7 @@ rapidjson::Value convert_optargs(const Term &src,
}

rapidjson::Value convert_term_tree(const Term &src,
rapidjson::MemoryPoolAllocator<> *allocator) {
rapidjson::MAYBE_POOL_ALLOCATOR *allocator) {
guarantee(src.has_type());

rapidjson::Value dest(rapidjson::kArrayType);
Expand Down

0 comments on commit 851b2f7

Please sign in to comment.