mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-27 19:10:24 +01:00
Standardize MemoryPoolAllocator::Realloc() also, and improve coverage
This commit is contained in:
@@ -189,6 +189,9 @@ public:
|
|||||||
if (originalPtr == 0)
|
if (originalPtr == 0)
|
||||||
return Malloc(newSize);
|
return Malloc(newSize);
|
||||||
|
|
||||||
|
if (newSize == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Do not shrink if new size is smaller than original
|
// Do not shrink if new size is smaller than original
|
||||||
if (originalSize >= newSize)
|
if (originalSize >= newSize)
|
||||||
return originalPtr;
|
return originalPtr;
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ void TestAllocator(Allocator& a) {
|
|||||||
EXPECT_EQ(i, r[i]);
|
EXPECT_EQ(i, r[i]);
|
||||||
|
|
||||||
Allocator::Free(r);
|
Allocator::Free(r);
|
||||||
|
|
||||||
|
// Realloc to zero size
|
||||||
|
EXPECT_TRUE(a.Realloc(a.Malloc(1), 1, 0) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Allocator, CrtAllocator) {
|
TEST(Allocator, CrtAllocator) {
|
||||||
|
|||||||
Reference in New Issue
Block a user