fix memory leak

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2317 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-07-24 11:39:38 +00:00
parent 31a83403af
commit bf9c99bb37

View File

@ -73,7 +73,6 @@ int MathArray::item_size(int pos) const
{ {
return 2 + (isInset(pos) ? sizeof(MathInset*) : 1); return 2 + (isInset(pos) ? sizeof(MathInset*) : 1);
} }
void MathArray::substitute(MathMacro const & m) void MathArray::substitute(MathMacro const & m)
@ -114,11 +113,13 @@ MathInset * MathArray::prevInset(int pos) const
return nextInset(pos); return nextInset(pos);
} }
unsigned char MathArray::GetChar(int pos) const unsigned char MathArray::GetChar(int pos) const
{ {
return pos < size() ? bf_[pos + 1] : '\0'; return pos < size() ? bf_[pos + 1] : '\0';
} }
string MathArray::GetString(int & pos) const string MathArray::GetString(int & pos) const
{ {
string s; string s;
@ -134,11 +135,13 @@ string MathArray::GetString(int & pos) const
return s; return s;
} }
MathTextCodes MathArray::GetCode(int pos) const MathTextCodes MathArray::GetCode(int pos) const
{ {
return pos < size() ? MathTextCodes(bf_[pos]) : LM_TC_MIN; return pos < size() ? MathTextCodes(bf_[pos]) : LM_TC_MIN;
} }
void MathArray::setCode(int pos, MathTextCodes t) void MathArray::setCode(int pos, MathTextCodes t)
{ {
if (pos > size() || isInset(pos)) if (pos > size() || isInset(pos))
@ -147,6 +150,7 @@ void MathArray::setCode(int pos, MathTextCodes t)
bf_[pos + 2] = t; bf_[pos + 2] = t;
} }
void MathArray::insert(int pos, MathInset * p) void MathArray::insert(int pos, MathInset * p)
{ {
bf_.insert(bf_.begin() + pos, 2 + sizeof(p), LM_TC_INSET); 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)); memcpy(&bf_[pos + 1], &p, sizeof(p));
} }
void MathArray::insert(int pos, unsigned char b, MathTextCodes t) void MathArray::insert(int pos, unsigned char b, MathTextCodes t)
{ {
bf_.insert(bf_.begin() + pos, 3, t); bf_.insert(bf_.begin() + pos, 3, t);
@ -180,20 +185,24 @@ void MathArray::push_back(MathInset * p)
insert(size(), p); insert(size(), p);
} }
void MathArray::push_back(unsigned char b, MathTextCodes c) void MathArray::push_back(unsigned char b, MathTextCodes c)
{ {
insert(size(), b, c); insert(size(), b, c);
} }
void MathArray::push_back(MathArray const & array) void MathArray::push_back(MathArray const & array)
{ {
insert(size(), array); insert(size(), array);
} }
void MathArray::clear() void MathArray::clear()
{ {
for (int pos = 0; pos < size(); next(pos))
if (isInset(pos))
delete nextInset(pos);
bf_.clear(); bf_.clear();
} }
@ -264,7 +273,6 @@ void MathArray::dump2(ostream & os) const
} }
void MathArray::dump(ostream & os) const void MathArray::dump(ostream & os) const
{ {
for (int pos = 0; pos < size(); next(pos)) { for (int pos = 0; pos < size(); next(pos)) {