cleanup... we are hopefully leaking a bit less already Andre' -- André Pönitz ........................................ [EMAIL PROTECTED]
Index: ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v retrieving revision 1.34 diff -u -p -u -r1.34 ChangeLog --- ChangeLog 2001/02/19 14:16:57 1.34 +++ ChangeLog 2001/02/19 16:27:05 @@ -5,6 +5,9 @@ * math_iter.[Ch]: seperate Copy() from Copy(int, int) + * math_iter.[Ch]: remove SetData + several files: subsequent changes + 2001-02-14 André Pönitz <[EMAIL PROTECTED]> * array.[Ch]: remove constructor and enums ARRAY_MIN_SIZE and ARRAY_STEP Index: array.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/array.C,v retrieving revision 1.8 diff -u -p -u -r1.8 array.C --- array.C 2001/02/19 14:16:57 1.8 +++ array.C 2001/02/19 16:27:05 @@ -55,8 +55,7 @@ MathedArray::MathedArray(MathedArray con // deep copy // we'll not yet get exeption safety - MathedIter it; - it.SetData(this); + MathedIter it(this); while (it.OK()) { if (it.IsInset()) { MathedInset * inset = it.GetInset(); Index: math_iter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_iter.C,v retrieving revision 1.36 diff -u -p -u -r1.36 math_iter.C --- math_iter.C 2001/02/19 14:16:57 1.36 +++ math_iter.C 2001/02/19 16:27:05 @@ -43,11 +43,6 @@ MathedIter::MathedIter() {} -void MathedIter::SetData(MathedArray * a) -{ - array = a; Reset(); -} - MathedArray * MathedIter::GetData() const { @@ -403,11 +398,11 @@ MathedArray * MathedIter::Copy(int pos1, return 0; } - ipush(); - MathedArray * t = array; - MathedArray * a; - if (pos1 > 0 || pos2 <= array->last()) { + ipush(); + MathedArray * t = array; + MathedArray * a; + short fc = 0; if (pos1 > 0 && (*array)[pos1] > ' ') { for (int p = pos1; p >= 0; --p) { @@ -436,25 +431,26 @@ MathedArray * MathedIter::Copy(int pos1, } a->last(dx); (*a)[dx] = '\0'; - } else - a = new MathedArray(*array); - // this should be unnecessary and leak in some (most?) cases since - // a = new MathedArray(*array); makes already a deep copy... - // I guess it'll go soon... (Andre') - - SetData(a); - while (OK()) { - if (IsInset()) { - MathedInset * inset = GetInset(); - inset = inset->Clone(); - array->raw_pointer_insert(inset, pos + 1, sizeof(inset)); + array = a; + Reset(); + + while (OK()) { + if (IsInset()) { + MathedInset * inset = GetInset(); + inset = inset->Clone(); + array->raw_pointer_insert(inset, pos + 1, +sizeof(inset)); + } + Next(); } - Next(); + array = t; + ipop(); + + return a; } - array = t; - ipop(); - return a; + + // otherwise: full copy + return new MathedArray(*array); } Index: math_iter.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_iter.h,v retrieving revision 1.25 diff -u -p -u -r1.25 math_iter.h --- math_iter.h 2001/02/19 14:16:57 1.25 +++ math_iter.h 2001/02/19 16:27:05 @@ -109,8 +109,6 @@ public: /// void setNumCols(int n) { ncols = n; } /// - void SetData(MathedArray * a); - /// MathedArray * GetData() const; /// Copy every object MathedArray * Copy(); Index: math_macrotable.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotable.C,v retrieving revision 1.5 diff -u -p -u -r1.5 math_macrotable.C --- math_macrotable.C 2001/02/17 18:52:53 1.5 +++ math_macrotable.C 2001/02/19 16:27:05 @@ -49,9 +49,7 @@ void MathMacroTable::addTemplate(MathMac void MathMacroTable::builtinMacros() { - MathedIter iter; MathParInset * inset;// *arg; - MathedArray * array2; built = true; @@ -60,48 +58,56 @@ void MathMacroTable::builtinMacros() // This macro doesn't have arguments MathMacroTemplate * m = new MathMacroTemplate("notin"); // this leaks addTemplate(m); - MathedArray * array = new MathedArray; // this leaks - iter.SetData(array); - iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not), - LM_TC_INSET); // this leaks - m->setData(array); + { + MathedArray * array = new MathedArray; // this leaks + MathedIter iter(array); + iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not), + LM_TC_INSET); // this leaks + m->setData(array); + } // These two are only while we are still with LyX 2.x m = new MathMacroTemplate("emptyset"); // this leaks - addTemplate(m); - array = new MathedArray; // this leaks - iter.SetData(array); - iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not), - LM_TC_INSET); // this leaks - m->setData(array); + addTemplate(m); + { + MathedArray * array = new MathedArray; // this leaks + MathedIter iter(array); + iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not), + LM_TC_INSET); // this leaks + m->setData(array); + } m = new MathMacroTemplate("perp"); // this leaks addTemplate(m); - array = new MathedArray; // this leaks - iter.SetData(array); - iter.insert(LM_bot, LM_TC_BOP); - m->setData(array); + { + MathedArray * array = new MathedArray; // this leaks + MathedIter iter(array); + iter.insert(LM_bot, LM_TC_BOP); + m->setData(array); + } // binom has two arguments m = new MathMacroTemplate("binom", 2); addTemplate(m); - array = new MathedArray; - m->setData(array); - iter.SetData(array); - inset = new MathDelimInset('(', ')'); - iter.insertInset(inset, LM_TC_ACTIVE_INSET); - array = new MathedArray; - iter.SetData(array); - MathFracInset * frac = new MathFracInset(LM_OT_ATOP); - iter.insertInset(frac, LM_TC_ACTIVE_INSET); - inset->setData(array); - array = new MathedArray; - array2 = new MathedArray; - iter.SetData(array); - iter.insertInset(m->getMacroPar(0), LM_TC_INSET); - iter.SetData(array2); - iter.insertInset(m->getMacroPar(1), LM_TC_INSET); - frac->SetData(array, array2); + { + MathedArray * array = new MathedArray; + m->setData(array); + MathedIter iter(array); + inset = new MathDelimInset('(', ')'); + iter.insertInset(inset, LM_TC_ACTIVE_INSET); + array = new MathedArray; + MathedIter iter2(array); + MathFracInset * frac = new MathFracInset(LM_OT_ATOP); + iter2.insertInset(frac, LM_TC_ACTIVE_INSET); + inset->setData(array); + array = new MathedArray; + MathedArray * array2 = new MathedArray; + MathedIter iter3(array); + iter3.insertInset(m->getMacroPar(0), LM_TC_INSET); + MathedIter iter4(array2); + iter4.insertInset(m->getMacroPar(1), LM_TC_INSET); + frac->SetData(array, array2); + } /* // Cases has 1 argument Index: math_matrixinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.C,v retrieving revision 1.4 diff -u -p -u -r1.4 math_matrixinset.C --- math_matrixinset.C 2001/02/17 18:52:53 1.4 +++ math_matrixinset.C 2001/02/19 16:27:05 @@ -35,8 +35,7 @@ MathMatrixInset::MathMatrixInset(MathMat nc_(mt->nc_), nr_(0), ws_(mt->nc_), v_align_(mt->v_align_), h_align_(mt->h_align_) { - MathedIter it; - it.SetData(mt->GetData()); + MathedIter it(mt->GetData()); array = it.Copy(); if (mt->row_ != 0) { MathedRowSt * ro = 0;