Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: base/allocator/partition_allocator/partition_alloc.cc

Issue 2799323003: Fix PartitionAlloc cookies for large in-place reallocs (Closed)
Patch Set: Fix issue Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/allocator/partition_allocator/partition_alloc_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/partition_allocator/partition_alloc.cc
diff --git a/base/allocator/partition_allocator/partition_alloc.cc b/base/allocator/partition_allocator/partition_alloc.cc
index 439ce177d88a5061ce42e50b50b94f8f0a923a1e..b13f36bb530265099b5bb31cbe0918a73450a98a 100644
--- a/base/allocator/partition_allocator/partition_alloc.cc
+++ b/base/allocator/partition_allocator/partition_alloc.cc
@@ -1051,8 +1051,13 @@ void* PartitionReallocGeneric(PartitionRootGeneric* root,
// determine it is a win.
if (actual_new_size == actual_old_size) {
// Trying to allocate a block of size new_size would give us a block of
- // the same size as the one we've already got, so no point in doing
- // anything here.
+ // the same size as the one we've already got, so re-use the allocation
+ // after updating statistics (and cookies, if present).
+ PartitionPageSetRawSize(page, PartitionCookieSizeAdjustAdd(new_size));
+#if DCHECK_IS_ON()
+ // Write a new trailing cookie.
+ PartitionCookieWriteValue(static_cast<char*>(ptr) + new_size);
+#endif
return ptr;
}
« no previous file with comments | « no previous file | base/allocator/partition_allocator/partition_alloc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698