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

Unified Diff: components/metrics/leak_detector/custom_allocator.cc

Issue 1472693002: Revert of components/metrics: Add runtime memory leak detector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/metrics/leak_detector/custom_allocator.cc
diff --git a/components/metrics/leak_detector/custom_allocator.cc b/components/metrics/leak_detector/custom_allocator.cc
deleted file mode 100644
index 1f80a9712f8bb0146f1ee5cdad9a91b23e1ab496..0000000000000000000000000000000000000000
--- a/components/metrics/leak_detector/custom_allocator.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/metrics/leak_detector/custom_allocator.h"
-
-#include <stddef.h>
-
-namespace metrics {
-namespace leak_detector {
-
-namespace {
-
-// Wrappers around new and delete.
-void* DefaultAlloc(size_t size) {
- return new char[size];
-}
-void DefaultFree(void* ptr, size_t /* size */) {
- delete[] reinterpret_cast<char*>(ptr);
-}
-
-CustomAllocator::AllocFunc g_alloc_func = nullptr;
-CustomAllocator::FreeFunc g_free_func = nullptr;
-
-} // namespace
-
-// static
-void CustomAllocator::Initialize() {
- Initialize(&DefaultAlloc, &DefaultFree);
-}
-
-// static
-void CustomAllocator::Initialize(AllocFunc alloc_func, FreeFunc free_func) {
- g_alloc_func = alloc_func;
- g_free_func = free_func;
-}
-
-// static
-bool CustomAllocator::Shutdown() {
- g_alloc_func = nullptr;
- g_free_func = nullptr;
- return true;
-}
-
-// static
-bool CustomAllocator::IsInitialized() {
- return g_alloc_func && g_free_func;
-}
-
-// static
-void* CustomAllocator::Allocate(size_t size) {
- return g_alloc_func(size);
-}
-
-// static
-void CustomAllocator::Free(void* ptr, size_t size) {
- g_free_func(ptr, size);
-}
-
-} // namespace leak_detector
-} // namespace metrics
« no previous file with comments | « components/metrics/leak_detector/custom_allocator.h ('k') | components/metrics/leak_detector/leak_analyzer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698