From bf9c99bb373f26a3d76763d733c068c44d6a4d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 24 Jul 2001 11:39:38 +0000 Subject: [PATCH] fix memory leak git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2317 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/array.C | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mathed/array.C b/src/mathed/array.C index a15ec82ded..c73d888503 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -73,7 +73,6 @@ int MathArray::item_size(int pos) const { return 2 + (isInset(pos) ? sizeof(MathInset*) : 1); } - void MathArray::substitute(MathMacro const & m) @@ -114,11 +113,13 @@ MathInset * MathArray::prevInset(int pos) const return nextInset(pos); } + unsigned char MathArray::GetChar(int pos) const { return pos < size() ? bf_[pos + 1] : '\0'; } + string MathArray::GetString(int & pos) const { string s; @@ -134,11 +135,13 @@ string MathArray::GetString(int & pos) const return s; } + MathTextCodes MathArray::GetCode(int pos) const { return pos < size() ? MathTextCodes(bf_[pos]) : LM_TC_MIN; } + void MathArray::setCode(int pos, MathTextCodes t) { if (pos > size() || isInset(pos)) @@ -147,6 +150,7 @@ void MathArray::setCode(int pos, MathTextCodes t) bf_[pos + 2] = t; } + void MathArray::insert(int pos, MathInset * p) { bf_.insert(bf_.begin() + pos, 2 + sizeof(p), LM_TC_INSET); @@ -159,6 +163,7 @@ void MathArray::replace(int pos, MathInset * p) memcpy(&bf_[pos + 1], &p, sizeof(p)); } + void MathArray::insert(int pos, unsigned char b, MathTextCodes t) { bf_.insert(bf_.begin() + pos, 3, t); @@ -180,20 +185,24 @@ void MathArray::push_back(MathInset * p) insert(size(), p); } + void MathArray::push_back(unsigned char b, MathTextCodes c) { insert(size(), b, c); } + void MathArray::push_back(MathArray const & array) { insert(size(), array); } - void MathArray::clear() { + for (int pos = 0; pos < size(); next(pos)) + if (isInset(pos)) + delete nextInset(pos); bf_.clear(); } @@ -264,7 +273,6 @@ void MathArray::dump2(ostream & os) const } - void MathArray::dump(ostream & os) const { for (int pos = 0; pos < size(); next(pos)) {