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/util') 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 From 461c632c09b776955737c0390d8ba34b7e41d081 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Mon, 6 Aug 2012 08:19:00 -0400 Subject: More headers --- klm/util/probing_hash_table_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'klm/util') diff --git a/klm/util/probing_hash_table_test.cc b/klm/util/probing_hash_table_test.cc index 37ffeb53..be0fa859 100644 --- a/klm/util/probing_hash_table_test.cc +++ b/klm/util/probing_hash_table_test.cc @@ -4,7 +4,8 @@ #include #include #include - +#include +#include #include namespace util { -- cgit v1.2.3