From f8008ca34fcdd0673608ae3d34d1f66decfc1100 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 22 Aug 2015 20:43:04 +0000 Subject: [PATCH] Only define object_array_t::object_array_t if VALGRIND --- common/include/poison.h | 5 +++++ common/main/object.h | 7 ++++++- similar/main/object.cpp | 5 ++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/include/poison.h b/common/include/poison.h index 9100b589f..4c4f6ec38 100644 --- a/common/include/poison.h +++ b/common/include/poison.h @@ -10,6 +10,7 @@ static inline void DXX_MAKE_MEM_UNDEFINED(T *b, unsigned long l) (void)b;(void)l; #ifdef DXX_HAVE_POISON_VALGRIND VALGRIND_MAKE_MEM_UNDEFINED(b, l); +#define DXX_HAVE_POISON_UNDEFINED 1 #endif } @@ -54,3 +55,7 @@ static inline void DXX_POISON_MEMORY(T b, T e, const V &v) _DXX_POISON_MEMORY_RANGE(b, e, v); DXX_MAKE_MEM_UNDEFINED(b, e); } + +#ifndef DXX_HAVE_POISON_UNDEFINED +#define DXX_HAVE_POISON_UNDEFINED 0 +#endif diff --git a/common/main/object.h b/common/main/object.h index 3513b99f6..2c0f3710a 100644 --- a/common/main/object.h +++ b/common/main/object.h @@ -47,6 +47,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "compiler-type_traits.h" #include "fwdobject.h" #include "powerup.h" +#include "poison.h" // Object types enum object_type_t : int @@ -327,7 +328,7 @@ struct object { // control info, determined by CONTROL_TYPE union control_info { constexpr control_info() : - laser_info{} + light_info{} { } struct laser_info laser_info; @@ -411,7 +412,11 @@ struct object_array_t : array } template typename tt::enable_if::value, reference>::type operator[](T) const = delete; +#if DXX_HAVE_POISON_UNDEFINED object_array_t(); +#else + object_array_t() = default; +#endif object_array_t(const object_array_t &) = delete; object_array_t &operator=(const object_array_t &) = delete; }; diff --git a/similar/main/object.cpp b/similar/main/object.cpp index 585ac183b..bb4ff88b3 100644 --- a/similar/main/object.cpp +++ b/similar/main/object.cpp @@ -84,7 +84,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "compiler-range_for.h" #include "highest_valid.h" #include "partial_range.h" -#include "poison.h" using std::min; using std::max; @@ -154,12 +153,12 @@ void object_goto_next_viewer() } #endif +#if DXX_HAVE_POISON_UNDEFINED object_array_t::object_array_t() { DXX_MAKE_MEM_UNDEFINED(begin(), end()); - range_for (auto &o, *this) - o.type = OBJ_NONE; } +#endif objptridx_t obj_find_first_of_type(int type) {