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

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: Created 7 years, 1 month 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
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 // When defined, different heap allocators can be used via an environment 14 // When defined, different heap allocators can be used via an environment
14 // variable set before running the program. This may reduce the amount 15 // variable set before running the program. This may reduce the amount
15 // of inlining that we get with malloc/free/etc. Disabling makes it 16 // of inlining that we get with malloc/free/etc. Disabling makes it
16 // so that only tcmalloc can be used. 17 // so that only tcmalloc can be used.
17 #define ENABLE_DYNAMIC_ALLOCATOR_SWITCHING 18 #define ENABLE_DYNAMIC_ALLOCATOR_SWITCHING
18 19
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 do_free(p); 396 do_free(p);
396 } 397 }
397 398
398 #endif // WIN32 399 #endif // WIN32
399 400
400 #include "generic_allocators.cc" 401 #include "generic_allocators.cc"
401 402
402 } // extern C 403 } // extern C
403 404
404 namespace base { 405 namespace base {
406
407 bool UncheckedMalloc(size_t size, void** result) {
408 switch (allocator) {
409 case JEMALLOC:
410 *result = je_malloc(size);
411 case WINHEAP:
412 case WINLFH:
413 *result = win_heap_malloc(size);
414 case TCMALLOC:
415 *result = do_malloc(size);
416 }
417
418 return *result;
419 }
420
405 namespace allocator { 421 namespace allocator {
406 422
407 void SetupSubprocessAllocator() { 423 void SetupSubprocessAllocator() {
408 #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING 424 #ifdef ENABLE_DYNAMIC_ALLOCATOR_SWITCHING
409 size_t primary_length = 0; 425 size_t primary_length = 0;
410 getenv_s(&primary_length, NULL, 0, primary_name); 426 getenv_s(&primary_length, NULL, 0, primary_name);
411 427
412 size_t secondary_length = 0; 428 size_t secondary_length = 0;
413 char buffer[20]; 429 char buffer[20];
414 getenv_s(&secondary_length, buffer, sizeof(buffer), secondary_name); 430 getenv_s(&secondary_length, buffer, sizeof(buffer), secondary_name);
(...skipping 22 matching lines...) Expand all
437 void TCMallocDoFreeForTest(void* ptr) { 453 void TCMallocDoFreeForTest(void* ptr) {
438 do_free(ptr); 454 do_free(ptr);
439 } 455 }
440 456
441 size_t ExcludeSpaceForMarkForTest(size_t size) { 457 size_t ExcludeSpaceForMarkForTest(size_t size) {
442 return ExcludeSpaceForMark(size); 458 return ExcludeSpaceForMark(size);
443 } 459 }
444 460
445 } // namespace allocator. 461 } // namespace allocator.
446 } // namespace base. 462 } // namespace base.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698