We now set nodeTab[x] to NULL to prevent libxml2 on AMD/64 from dying.
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 28 Feb 2005 20:30:51 +0000 (20:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 28 Feb 2005 20:30:51 +0000 (20:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@146 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/marcdumper/marcdumper.c

index 90adf62..3c6ba4d 100644 (file)
@@ -192,30 +192,18 @@ int main (int argc, char **argv) {
 
                                                        xmlDocPtr doc = xmlParseMemory(result, rlen);
 
-                                                       if (!doc) {
-                                                               fprintf(stderr, "xmLParseMemory failed\n");
-                                                               continue;
-                                                       }
-
-                                                       //      xmlDocPtr doc_copy = xmlCopyDoc( doc, 1 );
-                                                       //char* holdings_expr = "/*/*[(local-name()='datafield' and "
-                                                       //      "(@tag!='035' and @tag!='999')) or local-name()!='datafield']";
-
-                                                       //char* marc_expr = "//*[@tag=\"999\"]";
+                                                       if (doc) {
+                                                               prune_doc( doc, prune );
+                                                               char* marc = _xml_to_string(doc);
+                                                               fprintf(stdout, "%s", marc);
 
-                                                       prune_doc( doc, prune );
-                                                       //prune_doc( doc_copy, holdings_expr );
+                                                               free(marc);
+                                                               xmlFreeDoc(doc);
 
-                                                       char* marc = _xml_to_string(doc);
-                                                       //char* holdings = _xml_to_string(doc_copy);
+                                                       } else {
 
-                                                       fprintf(stdout, "%s", marc);
-                                                       //fprintf(stderr, "%s", holdings);
-
-                                                       free(marc);
-                                                       //free(holdings);
-                                                       xmlFreeDoc(doc);
-                                                       //xmlFreeDoc(doc_copy);
+                                                               fprintf(stderr, "xmLParseMemory failed for record %d\n", counter);
+                                                       }
 
                                                }
 
@@ -294,8 +282,12 @@ void prune_doc( xmlDocPtr doc, char* xpath ) {
                xmlNodePtr cur_node = (xmlNodePtr) object->nodesetval->nodeTab[i];
                xmlUnlinkNode( cur_node );
                xmlFreeNode( cur_node );
+               object->nodesetval->nodeTab[i] = NULL;
        }
 
+       xmlXPathFreeObject(object);
+   xmlXPathFreeContext(xpathctx);      
+
        /* remove all comments and PI nodes */
        xmlNodePtr cur = doc->children;
        while(cur) {
@@ -306,8 +298,6 @@ void prune_doc( xmlDocPtr doc, char* xpath ) {
                cur = cur->next;
        }
 
-       xmlXPathFreeObject(object);
-   xmlXPathFreeContext(xpathctx);      
 
 }