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

Unified Diff: third_party/tcmalloc/chromium/src/gperftools/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: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/gperftools/custom_allocator.h
diff --git a/third_party/tcmalloc/chromium/src/gperftools/custom_allocator.h b/third_party/tcmalloc/chromium/src/gperftools/custom_allocator.h
new file mode 100644
index 0000000000000000000000000000000000000000..524176b7f3ba12d82f47b7e414ae693d1d7909e5
--- /dev/null
+++ b/third_party/tcmalloc/chromium/src/gperftools/custom_allocator.h
@@ -0,0 +1,26 @@
+// 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.
+
+#ifndef CUSTOM_ALLOCATOR_H_
+#define CUSTOM_ALLOCATOR_H_
+
+#include <stddef.h>
+
+// PERFTOOLS_DLL_DECL is unnecessary, as it is Windows specific.
+
+// A container class for using LowLevelAlloc with STL_Allocator. The functions
+// Allocate() and Free() must match the specificiations in STL_Allocator.
+class CustomAllocator {
jar (doing other things) 2015/08/21 02:48:43 Why are we using a class, rather than a namespace?
Simon Que 2015/08/21 05:44:05 This is required as a template type for STL_Alloca
jar (doing other things) 2015/08/21 17:32:31 I see. SGTM.
+ public:
+ // This is a stateless class, but there is static data within the module that
+ // needs to be created and deleted.
+ static void Initialize();
+ static bool Shutdown();
+ static bool IsInitialized();
+
+ static void* Allocate(size_t size);
+ static void Free(void* ptr, size_t size);
+};
+
+#endif // CUSTOM_ALLOCATOR_H_

Powered by Google App Engine
This is Rietveld 408576698