[librsvg: 12/14] rsvg_css_parse_color(): Don't copy the incoming string



commit 5f666a73b8dd0bd5d408962defe305322c628006
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Jan 24 12:27:47 2018 -0600

    rsvg_css_parse_color(): Don't copy the incoming string

 rust/src/color.rs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/rust/src/color.rs b/rust/src/color.rs
index 3aa0aff..4c098f8 100644
--- a/rust/src/color.rs
+++ b/rust/src/color.rs
@@ -6,6 +6,7 @@ use ::glib::translate::*;
 use parsers::Parse;
 use parsers::ParseError;
 use error::*;
+use util::utf8_cstr;
 
 // There are two quirks here:
 //
@@ -166,9 +167,9 @@ impl From<Result<Color, AttributeError>> for ColorSpec {
 pub extern fn rsvg_css_parse_color (string: *const libc::c_char,
                                     allow_inherit: AllowInherit,
                                     allow_current_color: AllowCurrentColor) -> ColorSpec {
-    let s = unsafe { String::from_glib_none (string) };
+    let s = unsafe { utf8_cstr(string) };
 
-    ColorSpec::from (Color::parse (&s, (allow_inherit, allow_current_color)))
+    ColorSpec::from (Color::parse (s, (allow_inherit, allow_current_color)))
 }
 
 #[cfg(test)]


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