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

Unified Diff: src/gpu/GrMemoryPool.cpp

Issue 1562813002: Add sentinel to GrMemoryPool's block header (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « src/gpu/GrMemoryPool.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrMemoryPool.cpp
diff --git a/src/gpu/GrMemoryPool.cpp b/src/gpu/GrMemoryPool.cpp
index 0fd7e90f6671dca1be2e95f5f28a98be2ffe7a5f..adf46846c889fc476ee8a7ef3b5fd99c9ee5e889 100644
--- a/src/gpu/GrMemoryPool.cpp
+++ b/src/gpu/GrMemoryPool.cpp
@@ -55,6 +55,7 @@ void* GrMemoryPool::allocate(size_t size) {
fSize += block->fSize;
SkDEBUGCODE(++fAllocBlockCnt);
}
+ SkASSERT(kAssignedMarker == fTail->fBlockSentinal);
SkASSERT(fTail->fFreeSize >= size);
intptr_t ptr = fTail->fCurrPtr;
// We stash a pointer to the block header, just before the allocated space,
@@ -80,6 +81,7 @@ void GrMemoryPool::release(void* p) {
SkASSERT(kAssignedMarker == allocData->fSentinal);
SkDEBUGCODE(allocData->fSentinal = kFreedMarker);
BlockHeader* block = allocData->fHeader;
+ SkASSERT(kAssignedMarker == block->fBlockSentinal);
if (1 == block->fLiveCount) {
// the head block is special, it is reset rather than deleted
if (fHead == block) {
@@ -119,6 +121,7 @@ GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) {
reinterpret_cast<BlockHeader*>(sk_malloc_throw(paddedSize));
// we assume malloc gives us aligned memory
SkASSERT(!(reinterpret_cast<intptr_t>(block) % kAlignment));
+ SkDEBUGCODE(block->fBlockSentinal = kAssignedMarker);
block->fLiveCount = 0;
block->fFreeSize = size;
block->fCurrPtr = reinterpret_cast<intptr_t>(block) + kHeaderSize;
@@ -128,6 +131,8 @@ GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) {
}
void GrMemoryPool::DeleteBlock(BlockHeader* block) {
+ SkASSERT(kAssignedMarker == block->fBlockSentinal);
+ SkDEBUGCODE(block->fBlockSentinal = kFreedMarker); // FWIW
sk_free(block);
}
@@ -138,6 +143,7 @@ void GrMemoryPool::validate() {
SkASSERT(block);
int allocCount = 0;
do {
+ SkASSERT(kAssignedMarker == block->fBlockSentinal);
allocCount += block->fLiveCount;
SkASSERT(prev == block->fPrev);
if (prev) {
« no previous file with comments | « src/gpu/GrMemoryPool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698