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

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

Issue 55333002: Make possible to check memory allocations inside chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased patch - upload to try Created 6 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 | « base/allocator/allocator.gyp ('k') | base/allocator/win_allocator.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <config.h> 7 #include <config.h>
8 #include "base/allocator/allocator_extension_thunks.h" 8 #include "base/allocator/allocator_extension_thunks.h"
9 #include "base/process/memory.h"
9 #include "base/profiler/alternate_timer.h" 10 #include "base/profiler/alternate_timer.h"
10 #include "base/sysinfo.h" 11 #include "base/sysinfo.h"
11 #include "jemalloc.h" 12 #include "jemalloc.h"
12 13
13 // This shim make it possible to use different allocators via an environment 14 // This shim make it possible to use different allocators via an environment
14 // variable set before running the program. This may reduce the 15 // variable set before running the program. This may reduce the
15 // amount of inlining that we get with malloc/free/etc. 16 // amount of inlining that we get with malloc/free/etc.
16 17
17 // TODO(mbelshe): Ensure that all calls to tcmalloc have the proper call depth 18 // TODO(mbelshe): Ensure that all calls to tcmalloc have the proper call depth
18 // from the "user code" so that debugging tools (HeapChecker) can work. 19 // from the "user code" so that debugging tools (HeapChecker) can work.
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 374 }
374 } 375 }
375 376
376 #endif // WIN32 377 #endif // WIN32
377 378
378 #include "generic_allocators.cc" 379 #include "generic_allocators.cc"
379 380
380 } // extern C 381 } // extern C
381 382
382 namespace base { 383 namespace base {
384
385 bool UncheckedMalloc(size_t size, void** result) {
386 switch (::allocator) {
387 case JEMALLOC:
388 *result = je_malloc(size);
Nico 2014/01/08 03:20:15 Don't these need break statements?
389 case WINHEAP:
390 case WINLFH:
391 *result = win_heap_malloc(size);
392 case TCMALLOC:
393 *result = do_malloc(size);
394 }
395
396 return *result;
397 }
398
383 namespace allocator { 399 namespace allocator {
384 400
385 void SetupSubprocessAllocator() { 401 void SetupSubprocessAllocator() {
386 size_t primary_length = 0; 402 size_t primary_length = 0;
387 getenv_s(&primary_length, NULL, 0, primary_name); 403 getenv_s(&primary_length, NULL, 0, primary_name);
388 404
389 size_t secondary_length = 0; 405 size_t secondary_length = 0;
390 char buffer[20]; 406 char buffer[20];
391 getenv_s(&secondary_length, buffer, sizeof(buffer), secondary_name); 407 getenv_s(&secondary_length, buffer, sizeof(buffer), secondary_name);
392 DCHECK_GT(sizeof(buffer), secondary_length); 408 DCHECK_GT(sizeof(buffer), secondary_length);
(...skipping 20 matching lines...) Expand all
413 void TCMallocDoFreeForTest(void* ptr) { 429 void TCMallocDoFreeForTest(void* ptr) {
414 do_free(ptr); 430 do_free(ptr);
415 } 431 }
416 432
417 size_t ExcludeSpaceForMarkForTest(size_t size) { 433 size_t ExcludeSpaceForMarkForTest(size_t size) {
418 return ExcludeSpaceForMark(size); 434 return ExcludeSpaceForMark(size);
419 } 435 }
420 436
421 } // namespace allocator. 437 } // namespace allocator.
422 } // namespace base. 438 } // namespace base.
OLDNEW
« no previous file with comments | « base/allocator/allocator.gyp ('k') | base/allocator/win_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698