Skip to content

Commit 9fe93bb

Browse files
committed
- replaced RAPIDJSON_NEW macro with variadic varient
1 parent 014097e commit 9fe93bb

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

include/rapidjson/allocators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class MemoryPoolAllocator {
236236
*/
237237
bool AddChunk(size_t capacity) {
238238
if (!baseAllocator_)
239-
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator());
239+
ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator);
240240
if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) {
241241
chunk->capacity = capacity;
242242
chunk->size = 0;

include/rapidjson/document.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
20882088
GenericValue<Encoding, Allocator>(type), allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
20892089
{
20902090
if (!allocator_)
2091-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
2091+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
20922092
}
20932093

20942094
//! Constructor
@@ -2101,7 +2101,7 @@ class GenericDocument : public GenericValue<Encoding, Allocator> {
21012101
allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()
21022102
{
21032103
if (!allocator_)
2104-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
2104+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
21052105
}
21062106

21072107
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS

include/rapidjson/internal/regex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ class GenericRegexSearch {
606606
{
607607
RAPIDJSON_ASSERT(regex_.IsValid());
608608
if (!allocator_)
609-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
609+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
610610
stateSet_ = static_cast<unsigned*>(allocator_->Malloc(GetStateSetSize()));
611611
state0_.template Reserve<SizeType>(regex_.stateCount_);
612612
state1_.template Reserve<SizeType>(regex_.stateCount_);

include/rapidjson/internal/stack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Stack {
183183
size_t newCapacity;
184184
if (stack_ == 0) {
185185
if (!allocator_)
186-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
186+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
187187
newCapacity = initialCapacity_;
188188
} else {
189189
newCapacity = GetCapacity();

include/rapidjson/pointer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ class GenericPointer {
758758
*/
759759
Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) {
760760
if (!allocator_) // allocator is independently owned.
761-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
761+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
762762

763763
size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens
764764
for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t)
@@ -806,7 +806,7 @@ class GenericPointer {
806806

807807
// Create own allocator if user did not supply.
808808
if (!allocator_)
809-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
809+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
810810

811811
// Count number of '/' as tokenCount
812812
tokenCount_ = 0;

include/rapidjson/rapidjson.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ RAPIDJSON_NAMESPACE_END
583583

584584
#ifndef RAPIDJSON_NEW
585585
///! customization point for global \c new
586-
#define RAPIDJSON_NEW(x) new x
586+
#define RAPIDJSON_NEW(type, ...) new type(__VA_ARGS__)
587587
#endif
588588
#ifndef RAPIDJSON_DELETE
589589
///! customization point for global \c delete

include/rapidjson/schema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ class GenericSchemaDocument {
13441344
schemaRef_(allocator, kInitialSchemaRefSize)
13451345
{
13461346
if (!allocator_)
1347-
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());
1347+
ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator);
13481348

13491349
typeless_ = static_cast<SchemaType*>(allocator_->Malloc(sizeof(SchemaType)));
13501350
new (typeless_) SchemaType(this, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), 0);
@@ -1823,7 +1823,7 @@ RAPIDJSON_MULTILINEMACRO_END
18231823

18241824
StateAllocator& GetStateAllocator() {
18251825
if (!stateAllocator_)
1826-
stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator());
1826+
stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator);
18271827
return *stateAllocator_;
18281828
}
18291829

0 commit comments

Comments
 (0)