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

Unified Diff: Source/wtf/PartitionAlloc.h

Issue 169523004: Add partitionAllocGetSize() for determining actual size of allocation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 | Source/wtf/PartitionAllocTest.cpp » ('j') | Source/wtf/PartitionAllocTest.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAlloc.h
diff --git a/Source/wtf/PartitionAlloc.h b/Source/wtf/PartitionAlloc.h
index b1354777c6686b1566ab0a8cb56722ce9aedc7d8..1500bb5ac79da2f81f308de6dbc3eae07a415b30 100644
--- a/Source/wtf/PartitionAlloc.h
+++ b/Source/wtf/PartitionAlloc.h
@@ -565,6 +565,24 @@ ALWAYS_INLINE void partitionFreeGeneric(PartitionRootGeneric* root, void* ptr)
#endif
}
+ALWAYS_INLINE size_t partitionAllocGetSize(PartitionRootGeneric* root, void* ptr)
+{
+#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
+ ASSERT_NOT_REACHED();
Chris Evans 2014/02/18 22:19:59 I think this definitely will be reached. We want t
+#else
+ ASSERT(root->initialized);
+ if (UNLIKELY(!ptr))
+ return 0;
Chris Evans 2014/02/18 22:19:59 For simplicity, maybe try not supporting passing i
+ ptr = partitionCookieFreePointerAdjust(ptr);
+ ASSERT(partitionPointerIsValid(ptr));
+ PartitionPage* page = partitionPointerToPage(ptr);
+ spinLockLock(&root->lock);
Chris Evans 2014/02/18 22:19:59 No need for locking, as covered separately. But de
+ size_t size = page->bucket->slotSize;
+ spinLockUnlock(&root->lock);
+ return partitionCookieSizeAdjustSubtract(size);
+#endif
+}
+
// N (or more accurately, N - sizeof(void*)) represents the largest size in
// bytes that will be handled by a SizeSpecificPartitionAllocator.
// Attempts to partitionAlloc() more than this amount will fail.
« no previous file with comments | « no previous file | Source/wtf/PartitionAllocTest.cpp » ('j') | Source/wtf/PartitionAllocTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698