Only define object_array_t::object_array_t if VALGRIND

This commit is contained in:
Kp 2015-08-22 20:43:04 +00:00
parent 37838329a1
commit f8008ca34f
3 changed files with 13 additions and 4 deletions

View file

@ -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

View file

@ -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<object, MAX_OBJECTS>
}
template <typename T>
typename tt::enable_if<!tt::is_integral<T>::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;
};

View file

@ -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)
{