Make sure all vvp_vector8_t::val_ bytes are initialized

Often the val_ array is treated as a word (for speed) so make sure
all the bytes of val_ are initialized, even if not used.
This commit is contained in:
Stephen Williams 2010-01-12 14:45:57 -08:00
parent b4f070e60b
commit 9fbb12d9cf
2 changed files with 3 additions and 0 deletions

View File

@ -2642,6 +2642,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that,
return;
if (size_ <= sizeof val_) {
ptr_ = 0; // Prefill all val_ bytes
for (unsigned idx = 0 ; idx < size_ ; idx += 1)
val_[idx] = vvp_scalar_t(that.value(idx),str0, str1).raw();
} else {

View File

@ -873,6 +873,7 @@ inline vvp_vector8_t::vvp_vector8_t(unsigned size__)
: size_(size__)
{
if (size_ <= sizeof val_) {
// This should set all the bytes of val_ to 0
ptr_ = 0;
} else {
ptr_ = new unsigned char[size_];
@ -914,6 +915,7 @@ inline bool vvp_vector8_t::eeq(const vvp_vector8_t&that) const
return true;
if (size_ <= sizeof val_)
// This is equivilent to memcmp(val_, that.val_, sizeof val_)==0
return ptr_ == that.ptr_;
else
return memcmp(ptr_, that.ptr_, size_) == 0;