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

more sanity checks

parent 73a27198
......@@ -472,7 +472,7 @@ class Baselines
shift=0;
while((idx_t(1)<<shift)<nchan) ++shift;
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);
for (size_t i=0; i<nchan; ++i)
{
......@@ -1293,6 +1293,7 @@ template<typename Serv> void wminmax(const GridderConfig &gconf,
template<typename T> void update_idx(vector<T> &v, vector<T> &vold,
const vector<T> &add, const vector<T> &del)
{
myassert(v.size()>=del.size(), "must not happen");
vold.resize(0);
vold.reserve((v.size()+add.size())-del.size());
auto iin=v.begin(), ein=v.end();
......@@ -1301,19 +1302,17 @@ template<typename T> void update_idx(vector<T> &v, vector<T> &vold,
while(iin!=ein)
{
if (irem!=erem)
{
while ((iin!=ein) && (irem!=erem) && (*iin==*irem))
{ ++irem; ++iin; } // skip the entries to be removed
if (iin==ein) break;
}
if (iadd!=eadd)
while ((iadd!=eadd) && (*iadd<*iin))
vold.push_back(*(iadd++));
vold.push_back(*(iin++));
if ((irem!=erem) && (*iin==*irem))
{ ++irem; ++iin; } // skip removed entry
else if ((iadd!=eadd) && (*iadd<*iin))
vold.push_back(*(iadd++)); // add new entry
else
vold.push_back(*(iin++));
}
myassert(irem==erem, "must not happen");
while(iadd!=eadd)
vold.push_back(*(iadd++));
myassert(vold.size()==(v.size()+add.size())-del.size(), "must not happen");
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