[librsvg] pixbuf: shorten C code



commit 72159084f7efc387f57d41e6876cdf1420fc6603
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Dec 29 12:17:03 2018 +0100

    pixbuf: shorten C code

 librsvg/rsvg-pixbuf.c | 35 +++++++++++------------------------
 1 file changed, 11 insertions(+), 24 deletions(-)
---
diff --git a/librsvg/rsvg-pixbuf.c b/librsvg/rsvg-pixbuf.c
index 1687cf42..9334ad17 100644
--- a/librsvg/rsvg-pixbuf.c
+++ b/librsvg/rsvg-pixbuf.c
@@ -41,38 +41,25 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-static GdkPixbuf *
-pixbuf_from_file_with_size_data (GFile *file,
-                                 struct RsvgSizeCallbackData *cb_data,
-                                 GError ** error)
-{
-    RsvgHandle *handle;
-    GdkPixbuf *retval;
-
-    handle = rsvg_handle_new_from_gfile_sync (file, 0, NULL, error);
-    if (!handle) {
-        return NULL;
-    }
-
-    rsvg_handle_set_size_callback (handle, _rsvg_size_callback, cb_data, NULL);
-
-    retval = rsvg_handle_get_pixbuf (handle);
-    g_object_unref (handle);
-
-    return retval;
-}
-
 static GdkPixbuf *
 rsvg_pixbuf_from_file_with_size_data (const gchar * file_name,
                                       struct RsvgSizeCallbackData *cb_data, 
                                       GError ** error)
 {
     GFile *file;
-    GdkPixbuf *pixbuf;
+    RsvgHandle *handle;
+    GdkPixbuf *pixbuf = NULL;
 
     file = g_file_new_for_path (file_name);
-    pixbuf = pixbuf_from_file_with_size_data (file, cb_data, error);
-    g_clear_object (&file);
+    handle = rsvg_handle_new_from_gfile_sync (file, 0, NULL, error);
+
+    if (handle) {
+        rsvg_handle_set_size_callback (handle, _rsvg_size_callback, cb_data, NULL);
+        pixbuf = rsvg_handle_get_pixbuf (handle);
+    }
+
+    g_object_unref (handle);
+    g_object_unref (file);
 
     return pixbuf;
 }


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