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

Side by Side Diff: base/allocator/allocator_shim.cc

Issue 2712503002: Add a comment to the allocator shim. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/allocator/allocator_shim.h" 5 #include "base/allocator/allocator_shim.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include <new> 9 #include <new>
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return ShimMemalign(GetCachedPageSize(), size, context); 240 return ShimMemalign(GetCachedPageSize(), size, context);
241 } 241 }
242 242
243 void* ShimPvalloc(size_t size) { 243 void* ShimPvalloc(size_t size) {
244 // pvalloc(0) should allocate one page, according to its man page. 244 // pvalloc(0) should allocate one page, according to its man page.
245 if (size == 0) { 245 if (size == 0) {
246 size = GetCachedPageSize(); 246 size = GetCachedPageSize();
247 } else { 247 } else {
248 size = (size + GetCachedPageSize() - 1) & ~(GetCachedPageSize() - 1); 248 size = (size + GetCachedPageSize() - 1) & ~(GetCachedPageSize() - 1);
249 } 249 }
250 // The third argument is nullptr because pvalloc is glibc only and does not
251 // exist on OSX/BSD systems.
250 return ShimMemalign(GetCachedPageSize(), size, nullptr); 252 return ShimMemalign(GetCachedPageSize(), size, nullptr);
251 } 253 }
252 254
253 void ShimFree(void* address, void* context) { 255 void ShimFree(void* address, void* context) {
254 const allocator::AllocatorDispatch* const chain_head = GetChainHead(); 256 const allocator::AllocatorDispatch* const chain_head = GetChainHead();
255 return chain_head->free_function(chain_head, address, context); 257 return chain_head->free_function(chain_head, address, context);
256 } 258 }
257 259
258 size_t ShimGetSizeEstimate(const void* address, void* context) { 260 size_t ShimGetSizeEstimate(const void* address, void* context) {
259 const allocator::AllocatorDispatch* const chain_head = GetChainHead(); 261 const allocator::AllocatorDispatch* const chain_head = GetChainHead();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Cross-checks. 335 // Cross-checks.
334 336
335 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 337 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
336 #error The allocator shim should not be compiled when building for memory tools. 338 #error The allocator shim should not be compiled when building for memory tools.
337 #endif 339 #endif
338 340
339 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \ 341 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \
340 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS) 342 (defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS)
341 #error This code cannot be used when exceptions are turned on. 343 #error This code cannot be used when exceptions are turned on.
342 #endif 344 #endif
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