From e5d6f4ae41009c26978ecd62668501af9762b0bc Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Fri, 3 Aug 2012 07:46:33 -0400 Subject: Zero-initialize newed memory in a test --- klm/util/probing_hash_table_test.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'klm') diff --git a/klm/util/probing_hash_table_test.cc b/klm/util/probing_hash_table_test.cc index ef68e5f2..37ffeb53 100644 --- a/klm/util/probing_hash_table_test.cc +++ b/klm/util/probing_hash_table_test.cc @@ -1,11 +1,12 @@ #include "util/probing_hash_table.hh" -#include - #define BOOST_TEST_MODULE ProbingHashTableTest #include +#include #include +#include + namespace util { namespace { @@ -27,10 +28,11 @@ struct Entry { typedef ProbingHashTable > Table; BOOST_AUTO_TEST_CASE(simple) { - char mem[Table::Size(10, 1.2)]; - memset(mem, 0, sizeof(mem)); + size_t size = Table::Size(10, 1.2); + boost::scoped_array mem(new char[size]); + memset(mem.get(), 0, size); - Table table(mem, sizeof(mem)); + Table table(mem.get(), size); const Entry *i = NULL; BOOST_CHECK(!table.Find(2, i)); Entry to_ins; -- cgit v1.2.3