aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrMemoryPool.h
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-01-06 07:04:46 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-06 07:04:46 -0800
commit19c6250cad89d0e06a737919da94d6bc5c85cb1a (patch)
treec45446f38ddcc8c19442952047f748c97cfe3d8f /src/gpu/GrMemoryPool.h
parentbc348f41a7d51ba2385ca1d2d2ffab3657559d16 (diff)
Add debug sentinel to GrMemoryPool to check for memory stomping
Diffstat (limited to 'src/gpu/GrMemoryPool.h')
-rw-r--r--src/gpu/GrMemoryPool.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gpu/GrMemoryPool.h b/src/gpu/GrMemoryPool.h
index 5e38a29c04..1dd1732ea9 100644
--- a/src/gpu/GrMemoryPool.h
+++ b/src/gpu/GrMemoryPool.h
@@ -68,11 +68,21 @@ private:
size_t fSize; ///< total allocated size of the block
};
+ static const uint32_t kAssignedMarker = 0xCDCDCDCD;
+ static const uint32_t kFreedMarker = 0xEFEFEFEF;
+
+ struct AllocHeader {
+#ifdef SK_DEBUG
+ uint32_t fSentinal; ///< known value to check for memory stomping (e.g., (CD)*)
+#endif
+ BlockHeader* fHeader; ///< pointer back to the block header in which an alloc resides
+ };
+
enum {
// We assume this alignment is good enough for everybody.
kAlignment = 8,
kHeaderSize = GR_CT_ALIGN_UP(sizeof(BlockHeader), kAlignment),
- kPerAllocPad = GR_CT_ALIGN_UP(sizeof(BlockHeader*), kAlignment),
+ kPerAllocPad = GR_CT_ALIGN_UP(sizeof(AllocHeader), kAlignment),
};
size_t fSize;
size_t fPreallocSize;