From 9ac73107c197158960e96e97b178ff2fe924b9c8 Mon Sep 17 00:00:00 2001 From: pjrm Date: Tue, 7 Apr 2009 07:38:27 +0000 Subject: [PATCH] functional noop: Change prepend_current_dir_if_relative to return the result rather than taking a pointer to where to put the result. (Clarifies that the existing value isn't used.) --- src/dir-util.cpp | 14 +++++++------- src/dir-util.h | 2 +- src/document.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dir-util.cpp b/src/dir-util.cpp index 6beff22bf..67db03628 100644 --- a/src/dir-util.cpp +++ b/src/dir-util.cpp @@ -252,16 +252,15 @@ erange: return (NULL); } -void -prepend_current_dir_if_relative (char **result, const gchar *uri) +gchar * +prepend_current_dir_if_relative(gchar const *uri) { if (!uri) { - *(result) = NULL; - return; + return NULL; } - char *full_path = (char *) g_malloc (1001); - char *cwd = g_get_current_dir(); + gchar *full_path = (gchar *) g_malloc (1001); + gchar *cwd = g_get_current_dir(); gsize bytesRead = 0; gsize bytesWritten = 0; @@ -273,9 +272,10 @@ prepend_current_dir_if_relative (char **result, const gchar *uri) &error); inkscape_rel2abs (uri, cwd_utf8, full_path, 1000); - *(result) = g_strdup (full_path); + gchar *ret = g_strdup (full_path); g_free (full_path); g_free (cwd); + return ret; } diff --git a/src/dir-util.h b/src/dir-util.h index f7d75e8e4..9bdfafa9e 100644 --- a/src/dir-util.h +++ b/src/dir-util.h @@ -16,7 +16,7 @@ char const *sp_relative_path_from_path(char const *path, char const *base); char const *sp_extension_from_path(char const *path); char *inkscape_rel2abs(char const *path, char const *base, char *result, size_t const size); char *inkscape_abs2rel(char const *path, char const *base, char *result, size_t const size); -void prepend_current_dir_if_relative(char **result, gchar const *uri); +gchar *prepend_current_dir_if_relative(gchar const *filename); #endif /* !SEEN_DIR_UTIL_H */ diff --git a/src/document.cpp b/src/document.cpp index 2a9014e3e..7dbfe0d2f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -275,7 +275,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, document->rroot = rroot; #ifndef WIN32 - prepend_current_dir_if_relative(&(document->uri), uri); + document->uri = prepend_current_dir_if_relative(uri); #else // FIXME: it may be that prepend_current_dir_if_relative works OK on windows too, test! document->uri = uri? g_strdup(uri) : NULL; @@ -628,7 +628,7 @@ void sp_document_set_uri(SPDocument *document, gchar const *uri) if (uri) { #ifndef WIN32 - prepend_current_dir_if_relative(&(document->uri), uri); + document->uri = prepend_current_dir_if_relative(uri); #else // FIXME: it may be that prepend_current_dir_if_relative works OK on windows too, test! document->uri = g_strdup(uri); -- 2.30.2