[Scummvm-cvs-logs] CVS: scummvm/gui util.cpp,1.1,1.2 util.h,1.1,1.2
Max Horn
fingolfin at users.sourceforge.net
Sat Jul 13 05:00:02 CEST 2002
Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv26419
Modified Files:
util.cpp util.h
Log Message:
added clear() methods to String and StringList; StringList destructor now doesn't leak anymore
Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/util.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.cpp 12 Jul 2002 16:24:11 -0000 1.1
+++ util.cpp 13 Jul 2002 11:59:39 -0000 1.2
@@ -159,6 +159,13 @@
return *this;
}
+void String::clear()
+{
+ _len = 0;
+ if (_str)
+ _str[0] = 0;
+}
+
void String::ensureCapacity(int new_len, bool keep_old)
{
if (new_len <= _capacity)
@@ -188,8 +195,12 @@
StringList::~StringList()
{
- if (_data)
+ if (_data) {
+ for (int i = 0; i < _capacity; i++)
+ if (_data[_size])
+ delete _data[_size];
free(_data);
+ }
}
@@ -217,7 +228,6 @@
_size++;
}
-
String& StringList::operator [](int idx)
{
assert(idx >= 0 && idx < _size);
@@ -228,6 +238,11 @@
{
assert(idx >= 0 && idx < _size);
return *_data[idx];
+}
+
+void String::clear()
+{
+ _len = 0;
}
void StringList::ensureCapacity(int new_len)
Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.h 12 Jul 2002 16:24:11 -0000 1.1
+++ util.h 13 Jul 2002 11:59:39 -0000 1.2
@@ -50,6 +50,8 @@
operator const char *() const { return _str; }
const char *c_str() const { return _str; }
int size() const { return _len; }
+
+ void clear();
protected:
void ensureCapacity(int new_len, bool keep_old);
@@ -74,6 +76,8 @@
const String& operator [](int idx) const;
int size() const { return _size; }
+
+ void clear();
protected:
void ensureCapacity(int new_len);
More information about the Scummvm-git-logs
mailing list