summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-28 00:08:48 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-28 00:08:48 +0000
commit79be7e35a72365d861dd4140323275cac52a9e33 (patch)
tree1ad37b85c0f9482e36056502e299e3c2cd5fe7a9
parent8ff664a63254c2e64dc296caffc3a0261e2473af (diff)
value_array alloc fix
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@628 ec762483-ff6d-05da-a07a-a48fb63a330f
-rwxr-xr-xdecoder/apply_fsa_models.cc1
-rwxr-xr-xutils/value_array.h16
2 files changed, 9 insertions, 8 deletions
diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc
index fd3e1289..f9edb005 100755
--- a/decoder/apply_fsa_models.cc
+++ b/decoder/apply_fsa_models.cc
@@ -254,6 +254,7 @@ public:
adj.reinit_map(edge_for,*this);
#else
adj.reinit(edge_for.size());
+ SHOWM3(DBUILDTRIE,"done_building_reinit",edge_for.size(),adj.size(),2);
Adj::iterator o=adj.begin();
for (PrefixTrieEdgeFor::iterator i=edge_for.begin(),e=edge_for.end();i!=e;++i) {
SHOWM3(DBUILDTRIE,"edge_for",o-adj.begin(),i->first,i->second);
diff --git a/utils/value_array.h b/utils/value_array.h
index 3a8b3292..2010fefe 100755
--- a/utils/value_array.h
+++ b/utils/value_array.h
@@ -57,7 +57,7 @@ public:
typedef T* pointer;
size_type size() const { return sz; }
- bool empty() const { return size() == 0; }
+ bool empty() const { return !sz; }
iterator begin() { return array; }
iterator end() { return array + sz; }
@@ -87,15 +87,15 @@ protected:
{
if (!array) return;
// it's cool that this destroys in reverse order of construction, but why bother?
- for (size_type i = sz; i != 0;)
- A::destroy(array + --i);
+ for (pointer i=array+sz;i>array;)
+ A::destroy(--i);
}
void dealloc() {
- if (array != NULL) A::deallocate(array,sz);
+ if (sz && array != NULL) A::deallocate(array,sz);
sz=0;
}
void alloc(size_type s) {
- array = s==0 ? 0 : A::allocate(sz);
+ array = s==0 ? 0 : A::allocate(s);
sz=s;
}
@@ -133,11 +133,11 @@ protected:
copy_construct(itr,end,array);
}
inline void fill(const_reference t) {
- for (T *i=array,*e=array+sz;i!=e;++i)
+ for (pointer i=array,e=array+sz;i!=e;++i)
new(i) T(t);
}
inline void fill() {
- for (T *i=array,*e=array+sz;i!=e;++i)
+ for (pointer i=array,e=array+sz;i!=e;++i)
new(i) T();
}
@@ -184,7 +184,7 @@ public:
}
template <class I>
- void reinit(I itr, I end) {
+ void reinit_range(I itr, I end) {
reinit_noconstruct(std::distance(itr,end));
copy_construct(itr,end,array);
}