From f43a77b69610a80a87125ed1196207b06166cb8e Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 25 Apr 2007 01:00:45 +0000 Subject: Made fontNames array grow when needed. Fixes bug 1339845 and lessens memory use. --- src/ViewStyle.cxx | 15 +++++++++++++++ src/ViewStyle.h | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') 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