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

Side by Side Diff: courgette/memory_allocator.cc

Issue 10826014: Add a clarifying comment to the memory layout navigation. (Inspired by Coverity CID 100022) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mapping_.view() Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/memory_allocator.h" 5 #include "courgette/memory_allocator.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 TempMapping** write = reinterpret_cast<TempMapping**>(mapping_.view()); 130 TempMapping** write = reinterpret_cast<TempMapping**>(mapping_.view());
131 write[0] = this; 131 write[0] = this;
132 132
133 return true; 133 return true;
134 } 134 }
135 135
136 void* TempMapping::memory() const { 136 void* TempMapping::memory() const {
137 uint8* mem = reinterpret_cast<uint8*>(mapping_.view()); 137 uint8* mem = reinterpret_cast<uint8*>(mapping_.view());
138 // The 'this' pointer is written at the start of mapping_.view(), so
139 // go past it. (See Initialize()).
138 if (mem) 140 if (mem)
139 mem += sizeof(this); 141 mem += sizeof(this);
140 DCHECK(mem); 142 DCHECK(mem);
141 return mem; 143 return mem;
142 } 144 }
143 145
144 bool TempMapping::valid() const { 146 bool TempMapping::valid() const {
145 return mapping_.valid(); 147 return mapping_.valid();
146 } 148 }
147 149
148 // static 150 // static
149 TempMapping* TempMapping::GetMappingFromPtr(void* mem) { 151 TempMapping* TempMapping::GetMappingFromPtr(void* mem) {
150 TempMapping* ret = NULL; 152 TempMapping* ret = NULL;
151 if (mem) { 153 if (mem) {
152 ret = reinterpret_cast<TempMapping**>(mem)[-1]; 154 ret = reinterpret_cast<TempMapping**>(mem)[-1];
153 } 155 }
154 DCHECK(ret); 156 DCHECK(ret);
155 return ret; 157 return ret;
156 } 158 }
157 159
158 } // namespace courgette 160 } // namespace courgette
159 161
160 #endif // OS_WIN 162 #endif // OS_WIN
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698