| Index: Source/wtf/PartitionAlloc.cpp
|
| diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
|
| index f53b03a79ed2a7c4e740265c8bba758750a66ab1..9b9af0d6821f220f985029b9133e6d5e3f24920f 100644
|
| --- a/Source/wtf/PartitionAlloc.cpp
|
| +++ b/Source/wtf/PartitionAlloc.cpp
|
| @@ -46,6 +46,7 @@ void partitionAllocInit(PartitionRoot* root)
|
| {
|
| ASSERT(!root->initialized);
|
| root->initialized = true;
|
| + root->lock = 0;
|
| size_t i;
|
| for (i = 0; i < kNumBuckets; ++i) {
|
| PartitionBucket* bucket = &root->buckets[i];
|
| @@ -323,6 +324,36 @@ void partitionFreeSlowPath(PartitionPageHeader* page)
|
| }
|
| }
|
|
|
| +void* partitionReallocGeneric(PartitionRoot* root, void* ptr, size_t oldSize, size_t newSize)
|
| +{
|
| +#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
|
| + return realloc(ptr, newSize);
|
| +#else
|
| + size_t oldIndex = oldSize >> kBucketShift;
|
| + if (oldIndex > kNumBuckets)
|
| + oldIndex = kNumBuckets;
|
| + size_t newIndex = newSize >> kBucketShift;
|
| + if (newIndex > kNumBuckets)
|
| + newIndex = kNumBuckets;
|
| +
|
| + if (oldIndex == newIndex) {
|
| + // Same bucket. But kNumBuckets indicates the fastMalloc "bucket" so in
|
| + // that case we're not done; we have to forward to fastRealloc.
|
| + if (oldIndex == kNumBuckets)
|
| + return WTF::fastRealloc(ptr, newSize);
|
| + return ptr;
|
| + }
|
| + // This realloc cannot be resized in-place. Sadness.
|
| + void* ret = partitionAllocGeneric(root, newSize);
|
| + size_t copySize = oldSize;
|
| + if (newSize < oldSize)
|
| + copySize = newSize;
|
| + memcpy(ret, ptr, copySize);
|
| + partitionFreeGeneric(ptr, oldSize);
|
| + return ret;
|
| +#endif
|
| +}
|
| +
|
| #ifndef NDEBUG
|
|
|
| void partitionDumpStats(const PartitionRoot& root)
|
|
|