[gegl] Use modern realpath() everywhere



commit 594b2fae9c96981428e8fd9e2cd6198221f814f3
Author: Pino Toscano <toscano pino tiscali it>
Date:   Thu Apr 14 23:19:03 2016 +0200

    Use modern realpath() everywhere
    
    Assume everywhere that the realpath() implementation has the
    POSIX.1-2008 behaviour, i.e. allowing NULL as second parameter and thus
    returning a newly allocated buffer; it is not just a GNU extension.
    Also, this behaviour was assumed in other parts of gegl, so there should
    be no regression.
    
    This commit also reverts commit 5d715eee845ef1ab30490259a114902d0b6533ed.

 gegl/gegl-xml.c               |    4 ++--
 operations/core/load.c        |    5 +++--
 operations/external/ff-load.c |    5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gegl/gegl-xml.c b/gegl/gegl-xml.c
index 5260614..83069af 100644
--- a/gegl/gegl-xml.c
+++ b/gegl/gegl-xml.c
@@ -124,7 +124,6 @@ set_clone_prop_as_well:
           else
             {
               gchar * absolute_path;
-              gchar   temp_path[PATH_MAX];
               if (pd->path_root)
                 {
                   buf = g_strdup_printf ("%s/%s", pd->path_root, param_value);
@@ -134,11 +133,12 @@ set_clone_prop_as_well:
                   buf = g_strdup_printf ("./%s", param_value);
                 }
 
-              absolute_path = realpath (buf, temp_path);
+              absolute_path = realpath (buf, NULL);
               g_free (buf);
               if (absolute_path)
                 {
                   gegl_node_set (new, param_name, absolute_path, NULL);
+                  free (absolute_path);
                 }
               else
                 {
diff --git a/operations/core/load.c b/operations/core/load.c
index 67e8069..3140ebf 100644
--- a/operations/core/load.c
+++ b/operations/core/load.c
@@ -98,9 +98,9 @@ do_setup (GeglOperation *operation, const gchar *new_path, const gchar *new_uri)
     {
       const gchar *extension = strrchr (new_path, '.');
       const gchar *handler   = NULL;
-      char   resolved_path[PATH_MAX];
+      gchar *resolved_path;
 
-      realpath (new_path, resolved_path);
+      resolved_path = realpath (new_path, NULL);
 
       if (!g_file_test (resolved_path, G_FILE_TEST_EXISTS))
         {
@@ -127,6 +127,7 @@ do_setup (GeglOperation *operation, const gchar *new_path, const gchar *new_uri)
                          "path", resolved_path,
                          NULL);
         }
+      free (resolved_path);
     }
   else
     {
diff --git a/operations/external/ff-load.c b/operations/external/ff-load.c
index 40d26ce..73417c4 100644
--- a/operations/external/ff-load.c
+++ b/operations/external/ff-load.c
@@ -420,12 +420,13 @@ prepare (GeglOperation *operation)
       )
     {
       gint i;
-      gchar dereferenced_path[PATH_MAX];
+      gchar *dereferenced_path;
       gint err;
 
       ff_cleanup (o);
-      realpath (o->path, dereferenced_path);
+      dereferenced_path = realpath (o->path, NULL);
       err = avformat_open_input(&p->video_fcontext, dereferenced_path, NULL, 0);
+      free (dereferenced_path);
       if (err < 0)
         {
           print_error (o->path, err);


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