From b1ea463843add37874f9768b606825504cdc8eb2 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Fri, 13 Jun 2008 20:39:13 +0200 Subject: Hopefully fixed wrong libxml2 usage We did a xmlCleanupParser () call everytime we finished parsing; this is wrong (http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser) --- libpiano/main.c | 8 ++++++-- libpiano/xml.c | 5 ----- src/Makefile.am | 4 ++-- src/main.c | 4 ++++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/libpiano/main.c b/libpiano/main.c index e475b59..cc4e65a 100644 --- a/libpiano/main.c +++ b/libpiano/main.c @@ -32,7 +32,9 @@ THE SOFTWARE. #include "xml.h" #include "crypt.h" -/* initialize piano handle, set up curl handle and settings +/* initialize piano handle, set up curl handle and settings; note: you + * _must_ init curl and libxml2 using curl_global_init (CURL_GLOBAL_SSL) + * and xmlInitParser (), you also _must_ cleanup their garbage on your own! * @author PromyLOPh * @added 2008-06-05 * @param piano handle @@ -140,7 +142,9 @@ void PianoDestroyPlaylist (PianoHandle_t *ph) { ph->playlist = NULL; } -/* frees the whole piano handle structure +/* frees the whole piano handle structure; this will _not_ cleanup curl's + * internal garbage, you have to call curl_global_cleanup () and + * xmlCleanupParser () for libxml2 * @author PromyLOPh * @added 2008-06-05 * @param piano handle diff --git a/libpiano/xml.c b/libpiano/xml.c index 048f792..6f8cb55 100644 --- a/libpiano/xml.c +++ b/libpiano/xml.c @@ -203,7 +203,6 @@ void PianoXmlParseUserinfo (PianoHandle_t *ph, char *xml) { PianoXmlStructParser (structRoot, PianoXmlParseUserinfoCb, &ph->user); xmlFreeDoc (doc); - xmlCleanupParser(); } /* parse stations returned by pandora @@ -244,7 +243,6 @@ void PianoXmlParseStations (PianoHandle_t *ph, char *xml) { } xmlFreeDoc (doc); - xmlCleanupParser(); } /* parses playlist; used when searching too @@ -284,7 +282,6 @@ void PianoXmlParsePlaylist (PianoHandle_t *ph, char *xml) { } xmlFreeDoc (doc); - xmlCleanupParser(); } /* parse simple answers like this: @@ -310,7 +307,6 @@ PianoReturn_t PianoXmlParseSimple (char *xml) { } xmlFreeDoc (doc); - xmlCleanupParser(); return ret; } @@ -413,7 +409,6 @@ void PianoXmlParseSearch (char *searchXml, PianoXmlStructParser (structRoot, PianoXmlParseSearchCb, searchResult); xmlFreeDoc (doc); - xmlCleanupParser(); } /* encode reserved xml chars diff --git a/src/Makefile.am b/src/Makefile.am index fbd184c..20b5b40 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ bin_PROGRAMS = pianobar pianobar_SOURCES = main.c -pianobar_CPPFLAGS = ${LIBCURL_CFLAGS} ${LIBAO_CFLAGS} -I../libpiano -pianobar_LDADD = ${LIBCURL_LIBS} ${LIBAO_LIBS} ${LIBFAAD_LIBS} ${LIBREADLINE_LIBS} -lpthread ../libpiano/libpiano.la +pianobar_CPPFLAGS = ${LIBCURL_CFLAGS} ${LIBAO_CFLAGS} ${LIBXML_CFLAGS} -I../libpiano +pianobar_LDADD = ${LIBCURL_LIBS} ${LIBAO_LIBS} ${LIBFAAD_LIBS} ${LIBREADLINE_LIBS} ${LIBXML_LIBS} -lpthread ../libpiano/libpiano.la diff --git a/src/main.c b/src/main.c index 0dcac22..314748f 100644 --- a/src/main.c +++ b/src/main.c @@ -22,6 +22,8 @@ THE SOFTWARE. #include #include +#include +#include #include #include #include @@ -240,6 +242,7 @@ int main (int argc, char **argv) { /* init some things */ curl_global_init (CURL_GLOBAL_SSL); + xmlInitParser (); ao_initialize(); PianoInit (&ph); @@ -384,6 +387,7 @@ int main (int argc, char **argv) { PianoDestroy (&ph); curl_global_cleanup (); ao_shutdown(); + xmlCleanupParser (); return 0; } -- cgit v1.2.3