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

Unified Diff: third_party/tcmalloc/chromium/src/base/custom_allocator.h

Issue 986503002: components/metrics: Add runtime memory leak detector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove from gn build; keep it simple; can add it in later Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/base/custom_allocator.h
diff --git a/third_party/tcmalloc/chromium/src/base/custom_allocator.h b/third_party/tcmalloc/chromium/src/base/custom_allocator.h
new file mode 100644
index 0000000000000000000000000000000000000000..7ef286d95c88e3292c3f75bf46e1d4d3e79dd794
--- /dev/null
+++ b/third_party/tcmalloc/chromium/src/base/custom_allocator.h
@@ -0,0 +1,29 @@
+// Copyright (c) 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.
+
+// ---
+// Author: Simon Que
+
+#ifndef BASE_CUSTOM_ALLOCATOR_H_
+#define BASE_CUSTOM_ALLOCATOR_H_
+
+#include <stddef.h>
+
+#include "base/low_level_alloc.h"
+
+// A container class for using LowLevelAlloc with STL_Allocator. The functions
+// Allocate() and Free() must match the specificiations in STL_Allocator.
+class CustomAllocator {
+ public:
+ // If no arena is provided, LowLevelAlloc still uses its default arena.
+ static void SetArena(LowLevelAlloc::Arena* arena);
+
+ static void* Allocate(size_t size);
+ static void Free(void* ptr, size_t size);
+
+ private:
+ static LowLevelAlloc::Arena* arena_;
+};
+
+#endif // BASE_CUSTOM_ALLOCATOR_H_

Powered by Google App Engine
This is Rietveld 408576698