]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 5 May 2006 21:31:19 +0000 (21:31 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 5 May 2006 21:31:19 +0000 (21:31 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1377 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_xml.h
src/switch_xml.c

index a72473bd4a9da89a554b30a59d44fbef92b97709..953fc0658513b1c893265beb011875fc7775d52d 100644 (file)
@@ -33,6 +33,7 @@
 BEGIN_EXTERN_C
 
 #define SWITCH_XML_BUFSIZE 1024 // size of internal memory buffers
+
 #define SWITCH_XML_NAMEM   0x80 // name is malloced
 #define SWITCH_XML_TXTM    0x40 // txt is malloced
 #define SWITCH_XML_DUP     0x20 // attribute name and value are strduped
index a90aae7f0a6213a97aae4ac2d6d00ee35e4c1416..593dfd9a9caba2468be9eae7b1e21abb9a6048cb 100644 (file)
@@ -37,7 +37,8 @@ struct switch_xml_root {       // additional data for the root tag
     struct switch_xml xml;     // is a super-struct built on top of switch_xml struct
     switch_xml_t cur;          // current xml tree insertion point
     char *m;              // original xml string
-    size_t len;           // length of allocated memory for mmap, -1 for malloc
+    switch_size_t len;    // length of allocated memory for mmap
+       uint8_t dynamic;
     char *u;              // UTF-8 conversion of string if original was UTF-16
     char *s;              // start of work area
     char *e;              // end of work area
@@ -610,7 +611,7 @@ switch_xml_t switch_xml_parse_fp(FILE *fp)
 
     if (! s) return NULL;
     root = (switch_xml_root_t)switch_xml_parse_str(s, len);
-    root->len = -1; // so we know to free s in switch_xml_free()
+    root->dynamic = 1; // so we know to free s in switch_xml_free()
     return &root->xml;
 }
 
@@ -639,7 +640,7 @@ switch_xml_t switch_xml_parse_fd(int fd)
 #endif // HAVE_MMAP
         l = read(fd, m = malloc(st.st_size), st.st_size);
         root = (switch_xml_root_t)switch_xml_parse_str(m, l);
-        root->len = -1; // so we know to free s in switch_xml_free()
+        root->dynamic = 1; // so we know to free s in switch_xml_free()
 #ifdef HAVE_MMAP
     }
 #endif // HAVE_MMAP
@@ -804,7 +805,7 @@ void switch_xml_free(switch_xml_t xml)
         }            
         if (root->pi[0]) free(root->pi); // free processing instructions
 
-        if (root->len == -1) free(root->m); // malloced xml data
+        if (root->dynamic == 1) free(root->m); // malloced xml data
 #ifdef HAVE_MMAP
         else if (root->len) munmap(root->m, root->len); // mem mapped xml data
 #endif // HAVE_MMAP