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

Side by Side Diff: third_party/tcmalloc/chromium/src/custom_allocator.cc

Issue 986503002: components/metrics: Add runtime memory leak detector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix style, comments, RAW_CHECK in stl_allocator.h Created 5 years, 4 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
OLDNEW
(Empty)
1 // Copyright 2015 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 #include <gperftools/custom_allocator.h>
6
7 #include "base/low_level_alloc.h"
8
9 static LowLevelAlloc::Arena* g_arena = nullptr;
10
11 // static
12 void CustomAllocator::Initialize() {
13 g_arena = LowLevelAlloc::NewArena(0, LowLevelAlloc::DefaultArena());
14 }
15
16 // static
17 bool CustomAllocator::Shutdown() {
18 return LowLevelAlloc::DeleteArena(g_arena);
19 }
20
21 // static
22 bool CustomAllocator::IsInitialized() {
23 return g_arena;
24 }
25
26 // static
27 void* CustomAllocator::Allocate(size_t size) {
28 if (!g_arena)
29 return nullptr;
30
31 return LowLevelAlloc::AllocWithArena(size, g_arena);
32 }
33
34 // static
35 void CustomAllocator::Free(void* ptr, size_t /* size */) {
36 LowLevelAlloc::Free(ptr);
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698