Commit 04c1d771 authored by Martin Reinecke's avatar Martin Reinecke

more sanity checks

parent 73a27198
...@@ -472,7 +472,7 @@ class Baselines ...@@ -472,7 +472,7 @@ class Baselines
shift=0; shift=0;
while((idx_t(1)<<shift)<nchan) ++shift; while((idx_t(1)<<shift)<nchan) ++shift;
mask=(idx_t(1)<<shift)-1; mask=(idx_t(1)<<shift)-1;
myassert(nrows*nchan<hugeval, "too many entries in MS"); myassert(nrows*(mask+1)<hugeval, "too many entries in MS");
f_over_c.resize(nchan); f_over_c.resize(nchan);
for (size_t i=0; i<nchan; ++i) for (size_t i=0; i<nchan; ++i)
{ {
...@@ -1293,6 +1293,7 @@ template<typename Serv> void wminmax(const GridderConfig &gconf, ...@@ -1293,6 +1293,7 @@ template<typename Serv> void wminmax(const GridderConfig &gconf,
template<typename T> void update_idx(vector<T> &v, vector<T> &vold, template<typename T> void update_idx(vector<T> &v, vector<T> &vold,
const vector<T> &add, const vector<T> &del) const vector<T> &add, const vector<T> &del)
{ {
myassert(v.size()>=del.size(), "must not happen");
vold.resize(0); vold.resize(0);
vold.reserve((v.size()+add.size())-del.size()); vold.reserve((v.size()+add.size())-del.size());
auto iin=v.begin(), ein=v.end(); auto iin=v.begin(), ein=v.end();
...@@ -1301,19 +1302,17 @@ template<typename T> void update_idx(vector<T> &v, vector<T> &vold, ...@@ -1301,19 +1302,17 @@ template<typename T> void update_idx(vector<T> &v, vector<T> &vold,
while(iin!=ein) while(iin!=ein)
{ {
if (irem!=erem) if ((irem!=erem) && (*iin==*irem))
{ { ++irem; ++iin; } // skip removed entry
while ((iin!=ein) && (irem!=erem) && (*iin==*irem)) else if ((iadd!=eadd) && (*iadd<*iin))
{ ++irem; ++iin; } // skip the entries to be removed vold.push_back(*(iadd++)); // add new entry
if (iin==ein) break; else
} vold.push_back(*(iin++));
if (iadd!=eadd)
while ((iadd!=eadd) && (*iadd<*iin))
vold.push_back(*(iadd++));
vold.push_back(*(iin++));
} }
myassert(irem==erem, "must not happen");
while(iadd!=eadd) while(iadd!=eadd)
vold.push_back(*(iadd++)); vold.push_back(*(iadd++));
myassert(vold.size()==(v.size()+add.size())-del.size(), "must not happen");
v.swap(vold); v.swap(vold);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment