aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/ViewStyle.cxx15
-rw-r--r--src/ViewStyle.h3
2 files changed, 17 insertions, 1 deletions
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 6611439f5..1cf95cca2 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -25,11 +25,15 @@ MarginStyle::MarginStyle() :
// A list of the fontnames - avoids wasting space in each style
FontNames::FontNames() {
+ size = 8;
+ names = new char *[size];
max = 0;
}
FontNames::~FontNames() {
Clear();
+ delete []names;
+ names = 0;
}
void FontNames::Clear() {
@@ -47,6 +51,17 @@ const char *FontNames::Save(const char *name) {
return names[i];
}
}
+ if (max >= size) {
+ // Grow array
+ int sizeNew = size * 2;
+ char **namesNew = new char *[sizeNew];
+ for (int j=0;j<max;j++) {
+ namesNew[j] = names[j];
+ }
+ delete []names;
+ names = namesNew;
+ size = sizeNew;
+ }
names[max] = new char[strlen(name) + 1];
strcpy(names[max], name);
max++;
diff --git a/src/ViewStyle.h b/src/ViewStyle.h
index 86eae63c0..eb4e8dc11 100644
--- a/src/ViewStyle.h
+++ b/src/ViewStyle.h
@@ -23,7 +23,8 @@ public:
*/
class FontNames {
private:
- char *names[STYLE_MAX + 1];
+ char **names;
+ int size;
int max;
public: