X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=XMLTree.cpp;h=7d0c5e3c4d47aeffbaef88030f4a7e7d0e2a3293;hb=efe894650813a19a0e1408eb5807e59f037afc3b;hp=ea12fad9080f4a09c3f864d694e40a149f6eb3e2;hpb=e421727c5a512154cf2c3ff4cf8390eb88d527d7;p=SXSI%2FXMLTree.git diff --git a/XMLTree.cpp b/XMLTree.cpp index ea12fad..7d0c5e3 100644 --- a/XMLTree.cpp +++ b/XMLTree.cpp @@ -1,6 +1,5 @@ - #include "XMLTree.h" - +#include // functions to convert tag positions to the corresponding tree node and viceversa. // These are implemented in order to be able to change the tree and Tags representations, // without affecting the code so much. @@ -581,10 +580,8 @@ int XMLTree::OpenDocument(bool empty_texts, int sample_rate_text) fprintf(stderr, "Error: not enough memory\n"); return NULLT; } - setbit(par_aux,npar,OP); // marks a new opening parenthesis for the tree root - npar++; - tags_aux = (TagType *)malloc(sizeof(TagType)); + tags_aux = (TagType *) malloc(sizeof(TagType)); if (!tags_aux) { fprintf(stderr, "Error: not enough memory\n"); return NULLT; @@ -622,8 +619,6 @@ int XMLTree::CloseDocument() fprintf(stderr, "Error: not enough memory\n"); return NULLT; } - setbit(par_aux,npar,CP); - npar++; // creates the data structure for the tree topology Par = (bp *)malloc(sizeof(bp)); @@ -665,6 +660,7 @@ int XMLTree::NewOpenTag(unsigned char *tagname) fprintf(stderr, "Error: not enough memory\n"); return NULLT; } + setbit(par_aux,npar,OP); // marks a new opening parenthesis // transforms the tagname into a tag identifier. If the tag is new, we insert @@ -684,9 +680,7 @@ int XMLTree::NewOpenTag(unsigned char *tagname) TagName[i] = (unsigned char *)malloc(sizeof(unsigned char)*(strlen((const char *)tagname)+1)); strcpy((char *)TagName[i], (const char *)tagname); } - - tags_aux = (TagType *)realloc(tags_aux, sizeof(TagType)*(npar + 1)); - + tags_aux = (TagType *) realloc(tags_aux, sizeof(TagType)*(npar + 1)); if (!tags_aux) { fprintf(stderr, "Error: not enough memory\n"); return NULLT;