[librsvg] rsvg_xml_state_start_element(): Create the property bag here, not in the caller



commit 80dc358001686cc4f5acc41dbbdab1e0914d725c
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Dec 5 09:59:09 2018 -0600

    rsvg_xml_state_start_element(): Create the property bag here, not in the caller
    
    This makes the SAX callback just a stub for calling this function.

 librsvg/rsvg-load.c       | 9 ++-------
 rsvg_internals/src/xml.rs | 7 +++----
 2 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/librsvg/rsvg-load.c b/librsvg/rsvg-load.c
index 9ddd6ed3..3b2fac06 100644
--- a/librsvg/rsvg-load.c
+++ b/librsvg/rsvg-load.c
@@ -45,7 +45,7 @@ typedef struct RsvgXmlState RsvgXmlState;
 extern RsvgXmlState *rsvg_xml_state_new (RsvgHandle *handle);
 extern void rsvg_xml_state_free (RsvgXmlState *xml);
 extern gboolean rsvg_xml_state_tree_is_valid(RsvgXmlState *xml, GError **error);
-extern void rsvg_xml_state_start_element(RsvgXmlState *xml, RsvgHandle *handle, const char *name, 
RsvgPropertyBag atts);
+extern void rsvg_xml_state_start_element(RsvgXmlState *xml, RsvgHandle *handle, const char *name, const char 
**atts);
 extern void rsvg_xml_state_end_element(RsvgXmlState *xml, RsvgHandle *handle, const char *name);
 extern void rsvg_xml_state_characters(RsvgXmlState *xml, const char *unterminated_text, gsize len);
 extern void rsvg_xml_state_error(RsvgXmlState *xml, const char *msg);
@@ -313,17 +313,12 @@ rsvg_load_handle_xml_xinclude (RsvgHandle *handle, const char *href)
 static void
 sax_start_element_cb (void *data, const xmlChar *name, const xmlChar **atts)
 {
-    RsvgPropertyBag bag;
     RsvgLoad *load = data;
 
-    bag = rsvg_property_bag_new ((const char **) atts);
-
     rsvg_xml_state_start_element (load->xml.rust_state,
                                   load->handle,
                                   (const char *) name,
-                                  bag);
-
-    rsvg_property_bag_free (bag);
+                                  (const char **) atts);
 }
 
 static void
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 6c007ad1..6196231a 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -615,7 +615,7 @@ pub extern "C" fn rsvg_xml_state_start_element(
     xml: *mut RsvgXmlState,
     handle: *mut RsvgHandle,
     name: *const libc::c_char,
-    pbag: *const PropertyBag,
+    atts: *const *const libc::c_char,
 ) {
     assert!(!xml.is_null());
     let xml = unsafe { &mut *(xml as *mut XmlState) };
@@ -623,10 +623,9 @@ pub extern "C" fn rsvg_xml_state_start_element(
     assert!(!name.is_null());
     let name = unsafe { utf8_cstr(name) };
 
-    assert!(!pbag.is_null());
-    let pbag = unsafe { &*pbag };
+    let pbag = unsafe { PropertyBag::new_from_key_value_pairs(atts) };
 
-    xml.start_element(handle, name, pbag);
+    xml.start_element(handle, name, &pbag);
 }
 
 #[no_mangle]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]