diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-06-07 17:49:09 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-06-07 17:49:09 +0200 |
commit | dcb193fabc7af4776bdf0d31045f6801fa18000e (patch) | |
tree | 9f5dc66dad0fb614d7dcfbede519831bb26d34fc | |
parent | 1c77168443ac81aea3438a0a437beda8907eae47 (diff) |
Use object_wipe for clearing object in object_prep()
Also add a static_assert guard to make sure we're using
a POD.
-rw-r--r-- | src/object2.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/object2.cc b/src/object2.cc index 496b542d..a702930e 100644 --- a/src/object2.cc +++ b/src/object2.cc @@ -29,6 +29,7 @@ #include "xtra1.hpp" #include <cassert> +#include <type_traits> #include <vector> /* @@ -1937,6 +1938,7 @@ s16b lookup_kind(int tval, int sval) void object_wipe(object_type *o_ptr) { /* Wipe the structure */ + static_assert(std::is_pod<object_type>::value, "object_type must be POD type for memset to work"); memset(o_ptr, 0, sizeof(object_type)); } @@ -1959,7 +1961,7 @@ void object_prep(object_type *o_ptr, int k_idx) object_kind *k_ptr = &k_info[k_idx]; /* Clear the record */ - memset(o_ptr, 0, sizeof(object_type)); + object_wipe(o_ptr); /* Save the kind index */ o_ptr->k_idx = k_idx; |