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 | ac664bdb0e481539cf77098a7dd0e1ec8d937ba0 (patch) | |
tree | bed639c244b05d17137ebe9e44922f3c8c3de8c5 /klm/util | |
parent | 93f768b5c9a0ab54c462901e4edddacc65cb8ecf (diff) |
Zero-initialize newed memory in a test
Diffstat (limited to 'klm/util')
-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; |