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

Side by Side Diff: src/gpu/GrMemoryPool.h

Issue 1553233006: Add debug sentinel to GrMemoryPool to check for memory stomping (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 unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/GrMemoryPool.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrMemoryPool_DEFINED 8 #ifndef GrMemoryPool_DEFINED
9 #define GrMemoryPool_DEFINED 9 #define GrMemoryPool_DEFINED
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 BlockHeader* fNext; ///< doubly-linked list of blocks. 61 BlockHeader* fNext; ///< doubly-linked list of blocks.
62 BlockHeader* fPrev; 62 BlockHeader* fPrev;
63 int fLiveCount; ///< number of outstanding allocations in the 63 int fLiveCount; ///< number of outstanding allocations in the
64 ///< block. 64 ///< block.
65 intptr_t fCurrPtr; ///< ptr to the start of blocks free space. 65 intptr_t fCurrPtr; ///< ptr to the start of blocks free space.
66 intptr_t fPrevPtr; ///< ptr to the last allocation made 66 intptr_t fPrevPtr; ///< ptr to the last allocation made
67 size_t fFreeSize; ///< amount of free space left in the block. 67 size_t fFreeSize; ///< amount of free space left in the block.
68 size_t fSize; ///< total allocated size of the block 68 size_t fSize; ///< total allocated size of the block
69 }; 69 };
70 70
71 static const uint32_t kAssignedMarker = 0xCDCDCDCD;
72 static const uint32_t kFreedMarker = 0xEFEFEFEF;
73
74 struct AllocHeader {
75 #ifdef SK_DEBUG
76 uint32_t fSentinal; ///< known value to check for memory stomping ( e.g., (CD)*)
77 #endif
78 BlockHeader* fHeader; ///< pointer back to the block header in which an alloc resides
79 };
80
71 enum { 81 enum {
72 // We assume this alignment is good enough for everybody. 82 // We assume this alignment is good enough for everybody.
73 kAlignment = 8, 83 kAlignment = 8,
74 kHeaderSize = GR_CT_ALIGN_UP(sizeof(BlockHeader), kAlignment), 84 kHeaderSize = GR_CT_ALIGN_UP(sizeof(BlockHeader), kAlignment),
75 kPerAllocPad = GR_CT_ALIGN_UP(sizeof(BlockHeader*), kAlignment), 85 kPerAllocPad = GR_CT_ALIGN_UP(sizeof(AllocHeader), kAlignment),
76 }; 86 };
77 size_t fSize; 87 size_t fSize;
78 size_t fPreallocSize; 88 size_t fPreallocSize;
79 size_t fMinAllocSize; 89 size_t fMinAllocSize;
80 BlockHeader* fHead; 90 BlockHeader* fHead;
81 BlockHeader* fTail; 91 BlockHeader* fTail;
82 #ifdef SK_DEBUG 92 #ifdef SK_DEBUG
83 int fAllocationCnt; 93 int fAllocationCnt;
84 int fAllocBlockCnt; 94 int fAllocBlockCnt;
85 #endif 95 #endif
86 }; 96 };
87 97
88 #endif 98 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrMemoryPool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698