Home | History | Annotate | Download | only in allocator
      1 // Copyright 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #if defined(TYPE_PROFILING)
      6 
      7 #include "base/allocator/type_profiler_tcmalloc.h"
      8 
      9 #include "base/allocator/type_profiler_control.h"
     10 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
     11 #include "third_party/tcmalloc/chromium/src/gperftools/type_profiler_map.h"
     12 
     13 namespace base {
     14 namespace type_profiler {
     15 
     16 void* NewInterceptForTCMalloc(void* ptr,
     17                               size_t size,
     18                               const std::type_info& type) {
     19   if (Controller::IsProfiling())
     20     InsertType(ptr, size, type);
     21 
     22   return ptr;
     23 }
     24 
     25 void* DeleteInterceptForTCMalloc(void* ptr,
     26                                  size_t size,
     27                                  const std::type_info& type) {
     28   if (Controller::IsProfiling())
     29     EraseType(ptr);
     30 
     31   return ptr;
     32 }
     33 
     34 }  // namespace type_profiler
     35 }  // namespace base
     36 
     37 #endif  // defined(TYPE_PROFILING)
     38