[vlc-commits] commit: add xml_ReaderReset() ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Tue Jul 27 21:36:26 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 27 21:48:56 2010 +0300| [5330c52a29bbe0155bb05e49e21029e916cca9bd] | committer: Rémi Denis-Courmont 

add xml_ReaderReset()

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5330c52a29bbe0155bb05e49e21029e916cca9bd
---

 include/vlc_xml.h  |    1 +
 src/libvlccore.sym |    1 +
 src/misc/xml.c     |   23 +++++++++++++++++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/include/vlc_xml.h b/include/vlc_xml.h
index 740bc6d..cf29b22 100644
--- a/include/vlc_xml.h
+++ b/include/vlc_xml.h
@@ -73,6 +73,7 @@ struct xml_reader_t
 VLC_EXPORT( xml_reader_t *, xml_ReaderCreate, (vlc_object_t *, stream_t *) LIBVLC_USED );
 #define xml_ReaderCreate( a, s ) xml_ReaderCreate(VLC_OBJECT(a), s)
 VLC_EXPORT( void, xml_ReaderDelete, (xml_reader_t *) );
+VLC_EXPORT( xml_reader_t *, xml_ReaderReset, (xml_reader_t *, stream_t *) LIBVLC_USED );
 
 #define xml_ReaderRead( a ) a->pf_read( a )
 #define xml_ReaderNodeType( a ) a->pf_node_type( a )
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index dbbb2b4..494dd35 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -673,5 +673,6 @@ text_style_New
 xml_Delete
 xml_ReaderCreate
 xml_ReaderDelete
+xml_ReaderReset
 KeyToString
 StringToKey
diff --git a/src/misc/xml.c b/src/misc/xml.c
index f5e2fec..a76e4c3 100644
--- a/src/misc/xml.c
+++ b/src/misc/xml.c
@@ -101,3 +101,26 @@ void xml_ReaderDelete(xml_reader_t *reader)
     module_unneed(reader, reader->p_module);
     vlc_object_release(reader);
 }
+
+
+/**
+ * Resets an existing XML reader.
+ * If you need to parse several XML files, this function is much faster than
+ * xml_ReaderCreate() and xml_ReaderDelete() combined.
+ * @param reader XML reader to reinitialize
+ * @param stream new stream to read XML data from
+ * @return reader on success, NULL on error (in that case, the reader is
+ * destroyed).
+ */
+xml_reader_t *xml_ReaderReset(xml_reader_t *reader, stream_t *stream)
+{
+    module_stop(reader, reader->p_module);
+
+    reader->p_stream = stream;
+    if (module_start(reader, reader->p_module))
+    {
+        vlc_object_release(reader);
+        return NULL;
+    }
+    return reader;
+}



More information about the vlc-commits mailing list