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

Unified Diff: base/allocator/tcmalloc_unittest.cc

Issue 2028183002: tcmalloc_unittest: Use malloc and free directly, instead of tc_malloc and tc_free. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/tcmalloc_unittest.cc
diff --git a/base/allocator/tcmalloc_unittest.cc b/base/allocator/tcmalloc_unittest.cc
index 37c0ef61eff7dd2744cbd1c257c56af97c260495..5313bfdf65270f45db2d98783a3cf34286c06ea6 100644
--- a/base/allocator/tcmalloc_unittest.cc
+++ b/base/allocator/tcmalloc_unittest.cc
@@ -5,28 +5,27 @@
#include <stddef.h>
#include <stdio.h>
+#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/process/process_metrics.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_TCMALLOC)
-extern "C" {
-void* tc_malloc(size_t size);
-void tc_free(void*);
-}
-
namespace {
using std::min;
#ifdef NDEBUG
-void* TCMallocDoMallocForTest(size_t size) {
- return tc_malloc(size);
+// We wrap malloc and free in noinline functions to ensure that we test the real
+// implementation of the allocator. Otherwise, the compiler may specifically
+// recognize the calls to malloc and free in our tests and optimize them away.
+NOINLINE void* TCMallocDoMallocForTest(size_t size) {
Primiano Tucci (use gerrit) 2016/06/01 20:29:06 Oh, I would have never thought to this. right.
+ return malloc(size);
}
-void TCMallocDoFreeForTest(void* ptr) {
- tc_free(ptr);
+NOINLINE void TCMallocDoFreeForTest(void* ptr) {
+ free(ptr);
}
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698