From 903e4bd44bab47455f533915caaa95bd2fd2e99e Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 24 Jun 2007 12:02:23 +0000 Subject: Make the styles array variable length so it can be increased to 256 entries without always taking 24K. --- src/ViewStyle.cxx | 79 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 23 deletions(-) (limited to 'src/ViewStyle.cxx') diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 8f51fd5b9..f73c15ed1 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -29,15 +29,15 @@ MarginStyle::MarginStyle() : // A list of the fontnames - avoids wasting space in each style FontNames::FontNames() { - size = 8; - names = new char *[size]; + size = 8; + names = new char *[size]; max = 0; } FontNames::~FontNames() { Clear(); - delete []names; - names = 0; + delete []names; + names = 0; } void FontNames::Clear() { @@ -55,17 +55,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= size) { + // Grow array + int sizeNew = size * 2; + char **namesNew = new char *[sizeNew]; + for (int j=0;j STYLE_DEFAULT) { + for (; i= stylesSize) { + size_t sizeNew = stylesSize * 2; + while (sizeNew < index) + sizeNew *= 2; + AllocStyles(sizeNew); + } +} + void ViewStyle::ResetDefaultStyle() { styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0), ColourDesired(0xff,0xff,0xff), - Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()), + Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()), SC_CHARSET_DEFAULT, false, false, false, false, Style::caseMixed, true, true, false); } void ViewStyle::ClearStyles() { // Reset all styles to be like the default style - for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) { + for (unsigned int i=0; i