]> www.ginac.de Git - ginac.git/commitdiff
Fix two leaks in class pseries, where zero terms could have been created.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Mon, 19 Feb 2001 14:19:01 +0000 (14:19 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Mon, 19 Feb 2001 14:19:01 +0000 (14:19 +0000)
ginac/normal.cpp
ginac/pseries.cpp

index 6d0bdbd5ae67e3288fc99d1cbe222012bafd9f54..0832688dad690849f822a3542a76d372b5a2e992 100644 (file)
@@ -2060,15 +2060,13 @@ ex power::normal(lst &sym_lst, lst &repl_lst, int level) const
  *  @see ex::normal */
 ex pseries::normal(lst &sym_lst, lst &repl_lst, int level) const
 {
-       epvector new_seq;
-       new_seq.reserve(seq.size());
-
-       epvector::const_iterator it = seq.begin(), itend = seq.end();
-       while (it != itend) {
-               new_seq.push_back(expair(it->rest.normal(), it->coeff));
-               it++;
+       epvector newseq;
+       for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+               ex restexp = i->rest.normal();
+               if (!restexp.is_zero())
+                       newseq.push_back(expair(restexp, i->coeff));
        }
-       ex n = pseries(relational(var,point), new_seq);
+       ex n = pseries(relational(var,point), newseq);
        return (new lst(replace_with_symbol(n, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
 }
 
index 409947f473cad7cb41515979fb1dd76fd4800f95..78986b4da5da2939ce86c39f9a7961f389d8117a 100644 (file)
@@ -416,7 +416,6 @@ ex pseries::subs(const lst & ls, const lst & lr) const
 ex pseries::expand(unsigned options) const
 {
        epvector newseq;
-       newseq.reserve(seq.size());
        for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
                ex restexp = i->rest.expand();
                if (!restexp.is_zero())