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 @@ -639,6 +639,22 @@ RAPIDJSON_NAMESPACE_END
639
639
#endif // RAPIDJSON_ASSERT_THROWS
640
640
#endif // RAPIDJSON_NOEXCEPT_ASSERT
641
641
642
+ // /////////////////////////////////////////////////////////////////////////////
643
+ // malloc/realloc/free
644
+
645
+ #ifndef RAPIDJSON_MALLOC
646
+ // /! customization point for global \c malloc
647
+ #define RAPIDJSON_MALLOC (size ) std::malloc(size)
648
+ #endif
649
+ #ifndef RAPIDJSON_REALLOC
650
+ // /! customization point for global \c realloc
651
+ #define RAPIDJSON_REALLOC (ptr, new_size ) std::realloc(ptr, new_size)
652
+ #endif
653
+ #ifndef RAPIDJSON_FREE
654
+ // /! customization point for global \c free
655
+ #define RAPIDJSON_FREE (ptr ) std::free(ptr)
656
+ #endif
657
+
642
658
// /////////////////////////////////////////////////////////////////////////////
643
659
// new/delete
644
660
You can’t perform that action at this time.
0 commit comments