From e4cc12f3b98e9732e7c2ebf2b8a24d898801acf2 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 12 Jul 2013 10:55:44 -0700 Subject: [PATCH] Remove old comment and enclose sizeof value in parenthesis (vvp_vector8_t) --- vvp/vvp_net.cc | 20 +++++++++++--------- vvp/vvp_net.h | 15 ++++++--------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index 43ef8f1cd..353a3fb7b 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -2710,7 +2710,7 @@ ostream& operator<< (ostream&out, const vvp_vector2_t&that) vvp_vector8_t::vvp_vector8_t(const vvp_vector8_t&that) { size_ = that.size_; - if (size_ <= sizeof val_) { + if (size_ <= sizeof(val_)) { memcpy(val_, that.val_, sizeof val_); } else { ptr_ = new unsigned char[size_]; @@ -2725,7 +2725,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector4_t&that, if (size_ == 0) return; - if (size_ <= sizeof val_) { + 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(); @@ -2743,7 +2743,7 @@ vvp_vector8_t::vvp_vector8_t(const vvp_vector2_t&that, if (size_ == 0) return; - if (size_ <= sizeof val_) { + if (size_ <= sizeof(val_)) { ptr_ = 0; for (unsigned idx = 0 ; idx < size_ ; idx += 1) val_[idx] = vvp_scalar_t(that.value(idx)? BIT4_1:BIT4_0, str0, str1).raw(); @@ -2763,7 +2763,7 @@ vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that) return *this; if (size_ != that.size_) { - if (size_ > sizeof val_) + if (size_ > sizeof(val_)) delete[]ptr_; size_ = 0; } @@ -2773,7 +2773,7 @@ vvp_vector8_t& vvp_vector8_t::operator= (const vvp_vector8_t&that) return *this; } - if (that.size_ <= sizeof val_) { + if (that.size_ <= sizeof(val_)) { size_ = that.size_; memcpy(val_, that.val_, sizeof(val_)); return *this; @@ -2793,8 +2793,8 @@ vvp_vector8_t vvp_vector8_t::subvalue(unsigned base, unsigned wid) const { vvp_vector8_t tmp (wid); - unsigned char*tmp_ptr = tmp.size_ <= sizeof val_? tmp.val_ : tmp.ptr_; - const unsigned char*use_ptr = size_ <= sizeof val_? val_ : ptr_; + unsigned char*tmp_ptr = tmp.size_ <= sizeof(val_) ? tmp.val_ : tmp.ptr_; + const unsigned char*use_ptr = size_ <= sizeof(val_) ? val_ : ptr_; unsigned idx = 0; while ((idx < wid) && (base+idx < size_)) { @@ -2817,8 +2817,10 @@ vvp_vector8_t part_expand(const vvp_vector8_t&that, unsigned wid, unsigned off) assert(off < wid); vvp_vector8_t tmp (wid); - unsigned char* tmp_ptr = tmp.size_<= sizeof tmp.val_? tmp.val_ : tmp.ptr_; - const unsigned char* that_ptr = that.size_<= sizeof that.val_? that.val_ : that.ptr_; + unsigned char* tmp_ptr = tmp.size_<= sizeof(tmp.val_) ? + tmp.val_ : tmp.ptr_; + const unsigned char* that_ptr = that.size_<= sizeof(that.val_) ? + that.val_ : that.ptr_; unsigned idx = off; diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 3f05638b2..27e4999d7 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -882,9 +882,6 @@ class vvp_vector8_t { vvp_vector8_t& operator= (const vvp_vector8_t&that); private: - // This is the number of vvp_scalar_t objects we can keep in - // the val_ buffer. If the vector8 is bigger than this, then - // resort to allocations to get a larger buffer. unsigned size_; union { unsigned char*ptr_; @@ -924,8 +921,8 @@ extern ostream& operator<< (ostream&, const vvp_vector8_t&); inline vvp_vector8_t::vvp_vector8_t(unsigned size__) : size_(size__) { - if (size_ <= sizeof val_) { - memset(val_, 0, sizeof val_); + if (size_ <= sizeof(val_)) { + memset(val_, 0, sizeof(val_)); } else { ptr_ = new unsigned char[size_]; memset(ptr_, 0, size_); @@ -934,14 +931,14 @@ inline vvp_vector8_t::vvp_vector8_t(unsigned size__) inline vvp_vector8_t::~vvp_vector8_t() { - if (size_ > sizeof val_) + if (size_ > sizeof(val_)) delete[]ptr_; } inline vvp_scalar_t vvp_vector8_t::value(unsigned idx) const { assert(idx < size_); - if (size_ <= sizeof val_) + if (size_ <= sizeof(val_)) return vvp_scalar_t(val_[idx]); else return vvp_scalar_t(ptr_[idx]); @@ -950,7 +947,7 @@ inline vvp_scalar_t vvp_vector8_t::value(unsigned idx) const inline void vvp_vector8_t::set_bit(unsigned idx, vvp_scalar_t val) { assert(idx < size_); - if (size_ <= sizeof val_) + if (size_ <= sizeof(val_)) val_[idx] = val.raw(); else ptr_[idx] = val.raw(); @@ -965,7 +962,7 @@ inline bool vvp_vector8_t::eeq(const vvp_vector8_t&that) const if (size_ == 0) return true; - if (size_ <= sizeof val_) + if (size_ <= sizeof(val_)) // This is equivalent to memcmp(val_, that.val_, sizeof val_)==0 return ptr_ == that.ptr_; else