Split out the fake testing::MallocCounter into its own file.

Change-Id: I91569d8ec7280542e902af82915fb34bb8b0164c
Reviewed-on: https://code-review.googlesource.com/c/re2/+/46812
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/BUILD b/BUILD
index 1e1c753..3402447 100644
--- a/BUILD
+++ b/BUILD
@@ -111,6 +111,7 @@
         "re2/testing/string_generator.h",
         "re2/testing/tester.h",
         "util/benchmark.h",
+        "util/malloc_counter.h",
         "util/pcre.h",
         "util/test.h",
     ],
diff --git a/Makefile b/Makefile
index 0db70ad..4f12223 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,7 @@
 	util/benchmark.h\
 	util/flags.h\
 	util/logging.h\
+	util/malloc_counter.h\
 	util/mix.h\
 	util/mutex.h\
 	util/pcre.h\
diff --git a/re2/testing/dfa_test.cc b/re2/testing/dfa_test.cc
index f394c02..f0c6ffc 100644
--- a/re2/testing/dfa_test.cc
+++ b/re2/testing/dfa_test.cc
@@ -10,6 +10,7 @@
 #include "util/test.h"
 #include "util/flags.h"
 #include "util/logging.h"
+#include "util/malloc_counter.h"
 #include "util/strutil.h"
 #include "re2/prog.h"
 #include "re2/re2.h"
diff --git a/re2/testing/regexp_benchmark.cc b/re2/testing/regexp_benchmark.cc
index e1e29d0..33325c0 100644
--- a/re2/testing/regexp_benchmark.cc
+++ b/re2/testing/regexp_benchmark.cc
@@ -11,15 +11,16 @@
 #include <thread>
 #include <utility>
 
+#include "util/benchmark.h"
 #include "util/test.h"
 #include "util/flags.h"
 #include "util/logging.h"
+#include "util/malloc_counter.h"
 #include "util/strutil.h"
 #include "re2/prog.h"
 #include "re2/re2.h"
 #include "re2/regexp.h"
 #include "util/pcre.h"
-#include "util/benchmark.h"
 
 namespace re2 {
 void Test();
diff --git a/util/malloc_counter.h b/util/malloc_counter.h
new file mode 100644
index 0000000..81b564f
--- /dev/null
+++ b/util/malloc_counter.h
@@ -0,0 +1,19 @@
+// Copyright 2009 The RE2 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 UTIL_MALLOC_COUNTER_H_
+#define UTIL_MALLOC_COUNTER_H_
+
+namespace testing {
+class MallocCounter {
+ public:
+  MallocCounter(int x) {}
+  static const int THIS_THREAD_ONLY = 0;
+  long long HeapGrowth() { return 0; }
+  long long PeakHeapGrowth() { return 0; }
+  void Reset() {}
+};
+}  // namespace testing
+
+#endif  // UTIL_MALLOC_COUNTER_H_
diff --git a/util/test.h b/util/test.h
index de72a3f..3fed3d5 100644
--- a/util/test.h
+++ b/util/test.h
@@ -43,15 +43,4 @@
 #define EXPECT_GT CHECK_GT
 #define EXPECT_GE CHECK_GE
 
-namespace testing {
-class MallocCounter {
- public:
-  MallocCounter(int x) {}
-  static const int THIS_THREAD_ONLY = 0;
-  long long HeapGrowth() { return 0; }
-  long long PeakHeapGrowth() { return 0; }
-  void Reset() {}
-};
-}  // namespace testing
-
 #endif  // UTIL_TEST_H_