diff options
author | Kenneth Heafield <github@kheafield.com> | 2012-08-03 07:46:33 -0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2012-08-03 07:46:33 -0400 |
commit | e5d6f4ae41009c26978ecd62668501af9762b0bc (patch) | |
tree | 29479bace8b80ccd8eaefa550001be10e4aafa06 | |
parent | f3fef50a89e8e88da39e3c7000310c9e319d5cfc (diff) |
Zero-initialize newed memory in a test
-rw-r--r-- | klm/util/probing_hash_table_test.cc | 12 |
1 files changed, 7 insertions, 5 deletions
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 <stdint.h> - #define BOOST_TEST_MODULE ProbingHashTableTest #include <boost/test/unit_test.hpp> +#include <boost/scoped_array.hpp> #include <boost/functional/hash.hpp> +#include <stdint.h> + namespace util { namespace { @@ -27,10 +28,11 @@ struct Entry { typedef ProbingHashTable<Entry, boost::hash<unsigned char> > 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<char> 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; |