extras/XMLParser: Configurable character data buffer size
authorJerome St-Louis <jerome@ecere.com>
Thu, 26 Nov 2015 02:35:24 +0000 (21:35 -0500)
committerJerome St-Louis <jerome@ecere.com>
Mon, 21 Dec 2015 19:31:30 +0000 (14:31 -0500)
extras/XMLParser.ec

index ac93896..1822c6b 100644 (file)
@@ -66,6 +66,15 @@ class XMLParser
    int xmlDepth;
    bool closingTag;
    bool openingTag;
+   char * characterData;
+   uint charBufSize;
+
+   charBufSize = CHARBUFSIZE;
+
+   ~XMLParser()
+   {
+      delete characterData;
+   }
 
    bool GetWord()
    {
@@ -85,7 +94,7 @@ class XMLParser
       bool commented = false;
       byte lastCh = ' ';
       int stringPos;
-      char characterData[CHARBUFSIZE];
+      char * characterData = this.characterData;
       int charLen = 0;
       int oldDepth = xmlDepth;
       tag[0] = 0;
@@ -261,7 +270,9 @@ class XMLParser
          }
          else
          {
-            if(ch == '<' || charLen == CHARBUFSIZE - 1)
+            if(!characterData)
+               this.characterData = characterData = new byte[charBufSize];
+            if(ch == '<' || charLen == charBufSize - 1)
             {
                ProcessCharacterData(characterData);
                charLen = 0;