File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -77,19 +77,19 @@ class CrtAllocator {
77
77
static const bool kNeedFree = true ;
78
78
void * Malloc (size_t size) {
79
79
if (size) // behavior of malloc(0) is implementation defined.
80
- return std::malloc (size);
80
+ return RAPIDJSON_MALLOC (size);
81
81
else
82
82
return NULL ; // standardize to returning NULL.
83
83
}
84
84
void * Realloc (void * originalPtr, size_t originalSize, size_t newSize) {
85
85
(void )originalSize;
86
86
if (newSize == 0 ) {
87
- std::free (originalPtr);
87
+ RAPIDJSON_FREE (originalPtr);
88
88
return NULL ;
89
89
}
90
- return std::realloc (originalPtr, newSize);
90
+ return RAPIDJSON_REALLOC (originalPtr, newSize);
91
91
}
92
- static void Free (void *ptr) { std::free (ptr); }
92
+ static void Free (void *ptr) { RAPIDJSON_FREE (ptr); }
93
93
};
94
94
95
95
// /////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -617,6 +617,22 @@ RAPIDJSON_NAMESPACE_END
617
617
#define RAPIDJSON_NOEXCEPT_ASSERT (x ) RAPIDJSON_ASSERT(x)
618
618
#endif // RAPIDJSON_ASSERT_THROWS
619
619
620
+ // /////////////////////////////////////////////////////////////////////////////
621
+ // malloc/realloc/free
622
+
623
+ #ifndef RAPIDJSON_MALLOC
624
+ // /! customization point for global \c malloc
625
+ #define RAPIDJSON_MALLOC std::malloc
626
+ #endif
627
+ #ifndef RAPIDJSON_REALLOC
628
+ // /! customization point for global \c realloc
629
+ #define RAPIDJSON_REALLOC std::realloc
630
+ #endif
631
+ #ifndef RAPIDJSON_FREE
632
+ // /! customization point for global \c free
633
+ #define RAPIDJSON_FREE std::free
634
+ #endif
635
+
620
636
// /////////////////////////////////////////////////////////////////////////////
621
637
// new/delete
622
638
You can’t perform that action at this time.
0 commit comments