XML: Fix Windows compilation and free allocated memory 93/4793/5
Calixte DENIZET [Wed, 31 Aug 2011 08:33:20 +0000 (10:33 +0200)]
Change-Id: If3922da4f7906112858de5d726c3403c3ee02ef5

22 files changed:
scilab/modules/xml/LibScilab_Import.def
scilab/modules/xml/sci_gateway/cpp/sci_insertion.cpp
scilab/modules/xml/sci_gateway/cpp/sci_percent_XMLAttr_e.cpp
scilab/modules/xml/sci_gateway/cpp/sci_percent_c_i_XMLAttr.cpp
scilab/modules/xml/sci_gateway/cpp/sci_percent_foo_i_XMLList.cpp
scilab/modules/xml/sci_gateway/cpp/sci_percent_s_i_XMLList.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlAttrs.cpp [deleted file]
scilab/modules/xml/sci_gateway/cpp/sci_xmlClose.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlDocument.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlElement.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlGetNsByPrefix.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlReadStr.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlWrite.cpp
scilab/modules/xml/sci_gateway/cpp/sci_xmlXPath.cpp
scilab/modules/xml/src/c/DllmainXml.c
scilab/modules/xml/src/cpp/XMLDocument.cpp
scilab/modules/xml/src/cpp/XMLNodeList.cpp
scilab/modules/xml/src/cpp/XMLRhsValue.hxx
scilab/modules/xml/src/cpp/extraction.hpp
scilab/modules/xml/src/cpp/insertion.hpp
scilab/modules/xml/xml.vcxproj
scilab/modules/xml/xml.vcxproj.filters

index db4dac5..c3b36b0 100644 (file)
@@ -7,4 +7,7 @@ EXPORTS
  checklhs_
  com_
  intersci_
- putlhsvar_
\ No newline at end of file
+ putlhsvar_
+ scistring_
+ overload_
+ vstk_
\ No newline at end of file
index b120496..edd3c25 100644 (file)
 
 int sci_percent_c_i_XMLDoc(char *fname, unsigned long fname_len)
 {
-    return sci_insertion<XMLDocument, std::string>(fname, fname_len);
+    return sci_insertion<org_modules_xml::XMLDocument, std::string>(fname, fname_len);
 }
 /*--------------------------------------------------------------------------*/
 int sci_percent_XMLElem_i_XMLDoc(char *fname, unsigned long fname_len)
 {
-    return sci_insertion<XMLDocument, XMLElement>(fname, fname_len);
+    return sci_insertion<org_modules_xml::XMLDocument, XMLElement>(fname, fname_len);
 }
 /*--------------------------------------------------------------------------*/
 int sci_percent_c_i_XMLElem(char *fname, unsigned long fname_len)
@@ -55,7 +55,7 @@ int sci_percent_XMLElem_i_XMLList(char *fname, unsigned long fname_len)
 /*--------------------------------------------------------------------------*/
 int sci_percent_XMLDoc_i_XMLList(char *fname, unsigned long fname_len)
 {
-    return sci_XMLList_insertion<XMLDocument>(fname, fname_len);
+    return sci_XMLList_insertion<org_modules_xml::XMLDocument>(fname, fname_len);
 }
 /*--------------------------------------------------------------------------*/
 int sci_percent_c_i_XMLList(char *fname, unsigned long fname_len)
index 309fc92..537f4dd 100644 (file)
@@ -64,12 +64,14 @@ int sci_percent_XMLAttr_e(char * fname, unsigned long fname_len)
         err = getVarAddressFromPosition(pvApiCtx, 2, &nameaddr);
         if (err.iErr)
         {
+            freeAllocatedSingleString(prefix);
             printError(&err, 0);
             return 0;
         }
 
         if (!isStringType(pvApiCtx, nameaddr))
         {
+            freeAllocatedSingleString(prefix);
             Scierror(999, gettext("%s: Wrong type for input argument #%i: A string expected.\n"), fname, 1);
             return 0;
         }
@@ -80,6 +82,11 @@ int sci_percent_XMLAttr_e(char * fname, unsigned long fname_len)
     err = getVarAddressFromPosition(pvApiCtx, Rhs, &mlistaddr);
     if (err.iErr)
     {
+        freeAllocatedSingleString(prefix);
+        if (name)
+        {
+            freeAllocatedSingleString(name);
+        }
         printError(&err, 0);
         return 0;
     }
@@ -89,6 +96,11 @@ int sci_percent_XMLAttr_e(char * fname, unsigned long fname_len)
 
     if (!attr)
     {
+        freeAllocatedSingleString(prefix);
+        if (name)
+        {
+            freeAllocatedSingleString(name);
+        }
         Scierror(999, gettext("%s: XML object does not exist.\n"), fname);
         return 0;
     }
@@ -99,8 +111,13 @@ int sci_percent_XMLAttr_e(char * fname, unsigned long fname_len)
     }
     else
     {
-        name = prefix;
-        value = attr->getAttributeValue(const_cast<const char *>(name));
+        value = attr->getAttributeValue(const_cast<const char *>(prefix));
+    }
+
+    freeAllocatedSingleString(prefix);
+    if (name)
+    {
+        freeAllocatedSingleString(name);
     }
 
     if (!value)
index ae6bdba..7d371fa 100644 (file)
@@ -65,12 +65,14 @@ int sci_percent_c_i_XMLAttr(char * fname, unsigned long fname_len)
         err = getVarAddressFromPosition(pvApiCtx, 2, &nameaddr);
         if (err.iErr)
         {
+            freeAllocatedSingleString(prefix);
             printError(&err, 0);
             return 0;
         }
 
         if (!isStringType(pvApiCtx, nameaddr))
         {
+            freeAllocatedSingleString(prefix);
             Scierror(999, gettext("%s: Wrong type for input argument #%i: A string expected.\n"), fname, 1);
             return 0;
         }
@@ -81,6 +83,11 @@ int sci_percent_c_i_XMLAttr(char * fname, unsigned long fname_len)
     err = getVarAddressFromPosition(pvApiCtx, Rhs - 1, &rhsaddr);
     if (err.iErr)
     {
+        freeAllocatedSingleString(prefix);
+        if (name)
+        {
+            freeAllocatedSingleString(name);
+        }
         printError(&err, 0);
         return 0;
     }
@@ -88,6 +95,11 @@ int sci_percent_c_i_XMLAttr(char * fname, unsigned long fname_len)
     err = getVarAddressFromPosition(pvApiCtx, Rhs, &lhsaddr);
     if (err.iErr)
     {
+        freeAllocatedSingleString(prefix);
+        if (name)
+        {
+            freeAllocatedSingleString(name);
+        }
         printError(&err, 0);
         return 0;
     }
@@ -96,12 +108,22 @@ int sci_percent_c_i_XMLAttr(char * fname, unsigned long fname_len)
     a = XMLObject::getFromId<XMLAttr>(lhsid);
     if (!a)
     {
+        freeAllocatedSingleString(prefix);
+        if (name)
+        {
+            freeAllocatedSingleString(name);
+        }
         Scierror(999, gettext("%s: XML object does not exist.\n"), fname);
         return 0;
     }
 
     if (!isStringType(pvApiCtx, rhsaddr))
     {
+        freeAllocatedSingleString(prefix);
+        if (name)
+        {
+            freeAllocatedSingleString(name);
+        }
         Scierror(999, gettext("%s: Wrong type for input argument #%i: A string expected.\n"), fname, Rhs - 1);
         return 0;
     }
@@ -118,6 +140,13 @@ int sci_percent_c_i_XMLAttr(char * fname, unsigned long fname_len)
         a->setAttributeValue(prefix, name, value);
     }
 
+    freeAllocatedSingleString(prefix);
+    if (Rhs != 3)
+    {
+        freeAllocatedSingleString(name);
+    }
+    freeAllocatedSingleString(value);
+
     a->createOnStack(Rhs + 1);
     LhsVar(1) = Rhs + 1;
     PutLhsVar();
index 3a01b0b..8027aab 100644 (file)
@@ -16,6 +16,7 @@
 
 extern "C"
 {
+#include <string.h>
 #include <stdio.h>
 #include "gw_xml.h"
 #include "stack-c.h"
@@ -24,6 +25,10 @@ extern "C"
 #include "api_scilab.h"
 #include "xml_mlist.h"
 #include "localization.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
+
 }
 
 using namespace org_modules_xml;
@@ -115,6 +120,7 @@ int sci_percent_foo_i_XMLList(char * fname, unsigned long fname_len)
         if (retstr)
         {
             a->setElementAtPosition(index, std::string(retstr));
+            freeAllocatedSingleString(retstr);
             a->createOnStack(Rhs + 1);
             LhsVar(1) = Rhs + 1;
         }
index fb23c0d..2549054 100644 (file)
@@ -120,6 +120,7 @@ int sci_percent_s_i_XMLList(char * fname, unsigned long fname_len)
         if (retstr)
         {
             a->setElementAtPosition(index, std::string(retstr));
+            freeAllocatedSingleString(retstr);
             a->createOnStack(Rhs + 1);
             LhsVar(1) = Rhs + 1;
         }
diff --git a/scilab/modules/xml/sci_gateway/cpp/sci_xmlAttrs.cpp b/scilab/modules/xml/sci_gateway/cpp/sci_xmlAttrs.cpp
deleted file mode 100644 (file)
index 7032c48..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2011 - DIGITEO - Calixte DENIZET
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution.  The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "XMLObject.hxx"
-#include "XMLNs.hxx"
-#include "XMLElement.hxx"
-
-extern "C"
-{
-#include "gw_xml.h"
-#include "stack-c.h"
-#include "Scierror.h"
-#include "api_scilab.h"
-#include "xml_mlist.h"
-#include "localization.h"
-}
-
-using namespace org_modules_xml;
-
-/*--------------------------------------------------------------------------*/
-int sci_xmlNs(char * fname, unsigned long fname_len)
-{
-    int * addr = 0;
-    SciErr err;
-    XMLNs * ns = 0;
-    XMLElement * elem = 0;
-    char * prefix = 0;
-    char * href = 0;
-    int i = 0;
-    char ** vars[] = {&prefix, &href};
-
-    CheckLhs(1, 1);
-    CheckRhs(3, 3);
-
-    err = getVarAddressFromPosition(pvApiCtx, 1, &addr);
-    if (err.iErr)
-    {
-        printError(&err, 0);
-        return 0;
-    }
-
-    if (!isXMLElem(addr))
-    {
-        Scierror(999, gettext("%s: Wrong type for input argument #%i: A %s expected.\n"), fname, 1, "XMLElem");
-        return 0;
-    }
-
-    elem = XMLObject::getFromId<XMLElement>(getXMLObjectId(addr));
-    if (!elem)
-    {
-        Scierror(999, gettext("%s: XML Element does not exist.\n"), fname);
-        return 0;
-    }
-
-    for (; i < Rhs - 1; i++)
-    {
-        err = getVarAddressFromPosition(pvApiCtx, i + 2, &addr);
-        if (err.iErr)
-        {
-            printError(&err, 0);
-            return 0;
-        }
-
-        if (!isStringType(pvApiCtx, addr))
-        {
-            Scierror(999, gettext("%s: Wrong type for input argument #%i: A string expected.\n"), fname, i + 2);
-            return 0;
-        }
-
-        getAllocatedSingleString(pvApiCtx, addr, vars[i]);
-    }
-
-    ns = new XMLNs(elem, prefix, href);
-
-    for (i = 0; i < Rhs - 1; i++)
-    {
-        freeAllocatedSingleString(*(vars[i]));
-    }
-
-    if (!ns->createOnStack(Rhs + 1))
-    {
-        return 0;
-    }
-
-    LhsVar(1) = Rhs + 1;
-    PutLhsVar();
-
-    return 0;
-}
-/*--------------------------------------------------------------------------*/
index 58f0a4b..ef74108 100644 (file)
@@ -54,7 +54,7 @@ int sci_xmlClose(char * fname, unsigned long fname_len)
         getAllocatedSingleString(pvApiCtx, addr, &com);
         if (!strcmp(com, "all"))
         {
-            XMLDocument::closeAllDocuments();
+            org_modules_xml::XMLDocument::closeAllDocuments();
         }
         freeAllocatedSingleString(com);
     }
@@ -72,7 +72,7 @@ int sci_xmlClose(char * fname, unsigned long fname_len)
             if (isXMLDoc(addr))
             {
                 id = getXMLObjectId(addr);
-                doc = XMLObject::getFromId<XMLDocument>(id);
+                doc = XMLObject::getFromId<org_modules_xml::XMLDocument>(id);
                 if (!doc)
                 {
                     Scierror(999, gettext("%s: XML document does not exist.\n"), fname);
index 3d059dd..e9e4190 100644 (file)
@@ -30,7 +30,7 @@ int sci_xmlDocument(char * fname, unsigned long fname_len)
 {
     int * addr = 0;
     SciErr err;
-    XMLDocument * doc = 0;
+    org_modules_xml::XMLDocument * doc = 0;
     char * uri = 0;
     char * version = 0;
     int i = 0;
@@ -57,7 +57,7 @@ int sci_xmlDocument(char * fname, unsigned long fname_len)
         getAllocatedSingleString(pvApiCtx, addr, vars[i]);
     }
 
-    doc = new XMLDocument(uri, version);
+    doc = new org_modules_xml::XMLDocument(uri, version);
 
     for (i = 0; i < Rhs; i++)
     {
index 57e3711..89d7f2a 100644 (file)
@@ -30,7 +30,7 @@ using namespace org_modules_xml;
 /*--------------------------------------------------------------------------*/
 int sci_xmlElement(char * fname, unsigned long fname_len)
 {
-    XMLDocument * doc = 0;
+    org_modules_xml::XMLDocument * doc = 0;
     XMLElement * elem = 0;
     SciErr err;
     int * addr = 0;
@@ -52,7 +52,7 @@ int sci_xmlElement(char * fname, unsigned long fname_len)
         return 0;
     }
 
-    doc = XMLObject::getFromId<XMLDocument>(getXMLObjectId(addr));
+    doc = XMLObject::getFromId<org_modules_xml::XMLDocument>(getXMLObjectId(addr));
     if (!doc)
     {
         Scierror(999, gettext("%s: XML Document does not exist.\n"), fname);
@@ -74,7 +74,7 @@ int sci_xmlElement(char * fname, unsigned long fname_len)
 
     getAllocatedSingleString(pvApiCtx, addr, &name);
 
-    if (!name || !strlen(name) || xmlValidateName((const xmlChar *)name, 0))
+    if (!strlen(name) || xmlValidateName((const xmlChar *)name, 0))
     {
         freeAllocatedSingleString(name);
         Scierror(999, gettext("%s: Bad input argument #%i: A valid XML name expected.\n"), fname, 2);
@@ -82,6 +82,7 @@ int sci_xmlElement(char * fname, unsigned long fname_len)
     }
 
     elem = new XMLElement(*doc, name);
+    freeAllocatedSingleString(name);
     if (!elem->createOnStack(Rhs + 1))
     {
         return 0;
index aa5bc0f..37c4ade 100644 (file)
@@ -72,7 +72,6 @@ int sci_xmlGetNsByPrefix(char * fname, unsigned long fname_len)
     }
 
     getAllocatedSingleString(pvApiCtx, addr, &href);
-
     if (!strlen(href))
     {
         freeAllocatedSingleString(href);
index 5ed069a..786a2ca 100644 (file)
@@ -30,7 +30,7 @@ using namespace org_modules_xml;
 /*--------------------------------------------------------------------------*/
 int sci_xmlReadStr(char * fname, unsigned long fname_len)
 {
-    XMLDocument * doc;
+    org_modules_xml::XMLDocument * doc;
     SciErr err;
     int * addr = 0;
     std::string * code;
@@ -80,7 +80,7 @@ int sci_xmlReadStr(char * fname, unsigned long fname_len)
         validate = validateParam != 0;
     }
 
-    doc = new XMLDocument(*code, validate, &error);
+    doc = new org_modules_xml::XMLDocument(*code, validate, &error);
     delete code;
 
     if (error)
index 49a2f76..0bda94b 100644 (file)
@@ -16,7 +16,7 @@
 
 extern "C"
 {
-#include <stdio.h>
+#include <string.h>
 #include "gw_xml.h"
 #include "stack-c.h"
 #include "Scierror.h"
@@ -26,6 +26,9 @@ extern "C"
 #include "expandPathVariable.h"
 #include "MALLOC.h"
 #include "localization.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif 
 }
 
 using namespace org_modules_xml;
@@ -33,13 +36,12 @@ using namespace org_modules_xml;
 /*--------------------------------------------------------------------------*/
 int sci_xmlWrite(char * fname, unsigned long fname_len)
 {
-    XMLDocument * doc = 0;
+    org_modules_xml::XMLDocument * doc = 0;
     xmlDoc * document = 0;
     SciErr err;
     int * addr = 0;
     char * path = 0;
     const char * expandedPath = 0;
-    FILE * file = 0;
     int ret = 0;
 
     CheckLhs(1, 1);
@@ -58,7 +60,7 @@ int sci_xmlWrite(char * fname, unsigned long fname_len)
         return 0;
     }
 
-    doc = XMLObject::getFromId<XMLDocument>(getXMLObjectId(addr));
+    doc = XMLObject::getFromId<org_modules_xml::XMLDocument>(getXMLObjectId(addr));
     if (!doc)
     {
         Scierror(999, gettext("%s: XML Document does not exist.\n"), fname);
@@ -83,7 +85,7 @@ int sci_xmlWrite(char * fname, unsigned long fname_len)
 
         getAllocatedSingleString(pvApiCtx, addr, &path);
 
-        if (!path || !strlen(path))
+        if (!strlen(path))
         {
             freeAllocatedSingleString(path);
             Scierror(999, gettext("%s: Wrong size for input argument #%d: Non-empty string expected.\n"), fname, 2);
@@ -103,15 +105,7 @@ int sci_xmlWrite(char * fname, unsigned long fname_len)
         expandedPath = strdup((const char *)document->URL);
     }
 
-    file = fopen(expandedPath, "w");
-    if (!file)
-    {
-        Scierror(999, gettext("%s: Cannot write the file: %s\n"), fname, expandedPath);
-        FREE(expandedPath);
-        return 0;
-    }
-
-    ret = xmlDocDump(file, document);
+    ret = xmlSaveFile(expandedPath, document);
     if (ret == -1)
     {
         Scierror(999, gettext("%s: Cannot write the file: %s\n"), fname, expandedPath);
@@ -120,7 +114,6 @@ int sci_xmlWrite(char * fname, unsigned long fname_len)
     }
 
     FREE(expandedPath);
-    fclose(file);
 
     LhsVar(1) = 0;
     PutLhsVar();
index d8310a9..f31dc47 100644 (file)
@@ -86,12 +86,14 @@ int sci_xmlXPath(char * fname, unsigned long fname_len)
         err = getVarAddressFromPosition(pvApiCtx, 3, &addr);
         if (err.iErr)
         {
+            freeAllocatedSingleString(query);
             printError(&err, 0);
             return 0;
         }
 
         if (!isStringType(pvApiCtx, addr))
         {
+            freeAllocatedSingleString(query);
             Scierror(999, gettext("%s: Wrong type for input argument #%i: A string expected.\n"), fname, 2);
             return 0;
         }
@@ -99,12 +101,14 @@ int sci_xmlXPath(char * fname, unsigned long fname_len)
         err = getMatrixOfString(pvApiCtx, addr, &row, &col, 0, 0);
         if (err.iErr)
         {
+            freeAllocatedSingleString(query);
             printError(&err, 0);
             return 0;
         }
 
         if (col != 2)
         {
+            freeAllocatedSingleString(query);
             Scierror(999, gettext("%s: Bad number of columns for argument #%i: two expected.\n"), fname, 3);
             return 0;
         }
index c105c9a..d51435c 100644 (file)
@@ -14,6 +14,7 @@
 #include <windows.h> 
 /*--------------------------------------------------------------------------*/ 
 #pragma comment(lib,"../../bin/libxml2.lib")
+#pragma comment(lib,"../../bin/libintl.lib")
 /*--------------------------------------------------------------------------*/ 
 int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved)
 {
index 382a1c3..5483849 100644 (file)
@@ -226,8 +226,8 @@ namespace org_modules_xml
 
     void XMLDocument::closeAllDocuments()
     {
-        int size = openDocs.size();
-        XMLDocument * arr[size];
+        int size = (int)openDocs.size();
+        XMLDocument **arr = new XMLDocument*[size];
         int j = 0;
         for (std::list<XMLDocument *>::iterator i = openDocs.begin(); i != openDocs.end(); i++, j++)
         {
@@ -237,6 +237,7 @@ namespace org_modules_xml
         {
             delete arr[j];
         }
+        delete [] arr;
     }
 
     xmlDoc * XMLDocument::readDocument(const char * filename, bool validate, char ** error)
index 14a30ff..231a592 100644 (file)
@@ -47,7 +47,7 @@ namespace org_modules_xml
         for (xmlNode * cur = parent->children; cur; cur = cur->next)
         {
             xmlNodeDump(buffer, doc.getRealDocument(), cur, 0, 1);
-            xmlBufferAdd(buffer, (xmlChar *)"\n", strlen("\n"));
+            xmlBufferAdd(buffer, (xmlChar *)"\n", (int)strlen("\n"));
         }
         std::string str = std::string((const char *)buffer->content);
         xmlBufferFree(buffer);
@@ -172,7 +172,7 @@ namespace org_modules_xml
             setElementAtPosition(index, XMLElement(doc, list.getRealNode()));
             for (xmlNode * cur = list.getRealNode()->next; cur; cur = cur->next)
             {
-                setElementAtPosition((double)(pos++) + 0.5d, XMLElement(doc, cur));
+                setElementAtPosition((double)(pos++) + 0.5, XMLElement(doc, cur));
             }
         }
     }
index 92c14f3..f22795d 100644 (file)
@@ -72,8 +72,8 @@ namespace org_modules_xml
         static bool get(char * fname, int * addr, std::string ** obj)
             {
                 char ** str = 0;
-               int row = 0;
-               int col = 0;
+                int row = 0;
+                int col = 0;
                 std::string * code = new std::string("");
 
                 if (getAllocatedMatrixOfString(pvApiCtx, addr, &row, &col, &str))
index 65bd25c..ea52a49 100644 (file)
@@ -21,6 +21,7 @@
 
 extern "C"
 {
+#include <string.h>
 #include <stdio.h>
 #include "gw_xml.h"
 #include "stack-c.h"
@@ -29,6 +30,9 @@ extern "C"
 #include "xml_mlist.h"
 #include "xml_constants.h"
 #include "localization.h"
+#ifdef _MSC_VER
+#include "strdup_windows.h"
+#endif
 }
 
 using namespace org_modules_xml;
@@ -66,7 +70,7 @@ int createStringOnStack(char * fname, const char * str, int pos)
 
         if (vector.size())
         {
-            err = createMatrixOfString(pvApiCtx, pos, vector.size(), 1, const_cast<const char * const *>(&(vector[0])));
+            err = createMatrixOfString(pvApiCtx, pos, (int)vector.size(), 1, const_cast<const char * const *>(&(vector[0])));
         }
         else
         {
@@ -97,7 +101,7 @@ int createStringOnStack(char * fname, const char * str, int pos)
  * @param pos the stack position
  * @return 1 if all is ok, else 0
  */
-int createVariableOnStack(char * fname, XMLDocument & doc, const char * field, int pos)
+int createVariableOnStack(char * fname, org_modules_xml::XMLDocument & doc, const char * field, int pos)
 {
     if (!strcmp("root", field))
     {
@@ -268,11 +272,13 @@ int sci_extraction(char * fname, unsigned long fname_len)
     t = XMLObject::getFromId<T>(id);
     if (!t)
     {
+        freeAllocatedSingleString(field);
         Scierror(999, gettext("%s: XML object does not exist.\n"), fname);
         return 0;
     }
 
     ret = createVariableOnStack(fname, *t, const_cast<char *>(field), Rhs + 1);
+    freeAllocatedSingleString(field);
     if (ret)
     {
         LhsVar(1) = Rhs + 1;
index 71b4e8b..96696a3 100644 (file)
@@ -45,7 +45,7 @@ using namespace org_modules_xml;
  * @param value the new value
  */
 template <class T>
-bool setProperty(char * fname, XMLDocument & doc, const char * field, T & value)
+bool setProperty(char * fname, org_modules_xml::XMLDocument & doc, const char * field, T & value)
 {
     if (!strcmp("root", field))
     {
@@ -209,6 +209,7 @@ int sci_insertion(char * fname, unsigned long fname_len)
     a = XMLObject::getFromId<T>(lhsid);
     if (!a)
     {
+        freeAllocatedSingleString(field);
         Scierror(999, gettext("%s: XML object does not exist.\n"), fname);
         return 0;
     }
@@ -216,11 +217,13 @@ int sci_insertion(char * fname, unsigned long fname_len)
     success = XMLRhsValue::get(fname, rhsaddr, &b);
     if (!success)
     {
+        freeAllocatedSingleString(field);
         Scierror(999, gettext("%s: Error in getting rhs argument.\n"), fname);
         return 0;
     }
 
     success = setProperty<U>(fname, *a, const_cast<char *>(field), *b);
+    freeAllocatedSingleString(field);
 
     if (typeid(U) == typeid(std::string))
     {
index 2054440..3be3122 100644 (file)
     </Midl>
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>includes;src/c;src/cpp;../core/includes;../output_stream/includes;../fileio/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/libxml2;../api_scilab/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>includes;src/c;src/cpp;../core/includes;../output_stream/includes;../fileio/includes;../localization/includes;../../libs/MALLOC/includes;../../libs/intl;../../libs/libxml2;../api_scilab/includes;../windows_tools/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>FORDLL;_DEBUG;_WINDOWS;_USRDLL;XML_SCILAB_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <Project>{a5911cd7-f8e8-440c-a23e-4843a0636f3a}</Project>
       <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
     </ProjectReference>
+    <ProjectReference Include="..\windows_tools\src\c\scilab_windows\scilab_windows.vcxproj">
+      <Project>{8028f371-6a94-4a26-8804-6e7f05f1d1aa}</Project>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="src\cpp\extraction.hpp" />
+    <ClInclude Include="src\cpp\insertion.hpp" />
     <ClInclude Include="src\cpp\VariableScope.hxx" />
     <ClInclude Include="src\cpp\XMLAttr.hxx" />
     <ClInclude Include="src\cpp\XMLDocument.hxx" />
     <ClInclude Include="src\cpp\XMLElement.hxx" />
     <ClInclude Include="src\cpp\XMLList.hxx" />
+    <ClInclude Include="src\cpp\XMLList_insertion.hpp" />
     <ClInclude Include="src\cpp\XMLNodeList.hxx" />
     <ClInclude Include="src\cpp\XMLNodeSet.hxx" />
     <ClInclude Include="src\cpp\XMLNotHandledElement.hxx" />
     <ClInclude Include="src\cpp\XMLNs.hxx" />
     <ClInclude Include="src\cpp\XMLObject.hxx" />
+    <ClInclude Include="src\cpp\XMLRhsValue.hxx" />
     <ClInclude Include="src\cpp\XMLXPath.hxx" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="sci_gateway\cpp\sci_extraction.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_insertion.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_percent_c_i_XMLAttr.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_percent_foo_i_XMLList.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_percent_s_i_XMLList.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_percent_XMLAttr_e.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_percent_XMLAttr_length.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_percent_XMLAttr_size.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_percent_XMLList_e.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_percent_XMLList_length.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_percent_XMLList_size.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_print.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlAddNs.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_xmlClose.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlDocument.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_xmlDump.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlElement.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlFormat.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlGetNsByHref.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlGetNsByPrefix.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_xmlGetOpenStreams.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlNs.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_xmlRead.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlReadStr.cpp" />
+    <ClCompile Include="sci_gateway\cpp\sci_xmlWrite.cpp" />
     <ClCompile Include="sci_gateway\cpp\sci_xmlXPath.cpp" />
     <ClCompile Include="sci_gateway\c\gw_xml.c" />
     <ClCompile Include="src\cpp\VariableScope.cpp" />
     <ClCompile Include="src\cpp\XMLNs.cpp" />
     <ClCompile Include="src\cpp\XMLObject.cpp" />
     <ClCompile Include="src\cpp\XMLXPath.cpp" />
-    <ClCompile Include="src\c\createMlists.c" />
     <ClCompile Include="src\c\DllmainXml.c" />
+    <ClCompile Include="src\c\XMLMlistsManagement.c" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
index 4790be1..c57b2ce 100644 (file)
     <ClInclude Include="src\cpp\XMLXPath.hxx">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="src\cpp\insertion.hpp">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\cpp\XMLList_insertion.hpp">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="src\cpp\XMLRhsValue.hxx">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="src\cpp\VariableScope.cpp">
     <ClCompile Include="src\cpp\XMLXPath.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="src\c\createMlists.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="src\c\DllmainXml.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="sci_gateway\cpp\sci_xmlXPath.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="src\c\XMLMlistsManagement.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_insertion.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_percent_c_i_XMLAttr.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_percent_foo_i_XMLList.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_percent_s_i_XMLList.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_percent_XMLAttr_length.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_percent_XMLAttr_size.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_percent_XMLList_length.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlAddNs.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlDocument.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlElement.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlFormat.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlGetNsByHref.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlGetNsByPrefix.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlNs.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlReadStr.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="sci_gateway\cpp\sci_xmlWrite.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>
\ No newline at end of file