diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-16 20:08:35 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-16 20:08:35 +0000 |
commit | 6bacbfcbe191ec898e43f4f03e570283b156a8ca (patch) | |
tree | b81ddcf798cc7008b09d504687d319f429cd5bb3 /decoder/small_vector.h | |
parent | 15a587e247dc0954de27e2627f5511126243943d (diff) |
vest: oracle_loss argument bugfix
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@287 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/small_vector.h')
-rw-r--r-- | decoder/small_vector.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/decoder/small_vector.h b/decoder/small_vector.h index 800c1df1..86d3b0b3 100644 --- a/decoder/small_vector.h +++ b/decoder/small_vector.h @@ -3,6 +3,7 @@ #include <streambuf> // std::max - where to get this? #include <cstring> #include <cassert> +#include <limits.h> #define __SV_MAX_STATIC 2 @@ -77,10 +78,10 @@ class SmallVector { bool empty() const { return size_ == 0; } size_t size() const { return size_; } - inline void ensure_capacity(unsigned char min_size) { + inline void ensure_capacity(uint16_t min_size) { assert(min_size > __SV_MAX_STATIC); if (min_size < capacity_) return; - unsigned char new_cap = std::max(static_cast<unsigned char>(capacity_ << 1), min_size); + uint16_t new_cap = std::max(static_cast<uint16_t>(capacity_ << 1), min_size); int* tmp = new int[new_cap]; std::memcpy(tmp, data_.ptr, capacity_ * sizeof(int)); delete[] data_.ptr; @@ -170,8 +171,8 @@ class SmallVector { } private: - unsigned char capacity_; // only defined when size_ >= __SV_MAX_STATIC - unsigned char size_; + uint16_t capacity_; // only defined when size_ >= __SV_MAX_STATIC + uint16_t size_; union StorageType { int vals[__SV_MAX_STATIC]; int* ptr; |