Author: abrander
Date: 2010-01-28 18:48:34 +0100 (Thu, 28 Jan 2010)
New Revision: 3109
Modified:
branches/rawstudio-ng-color/librawstudio/rs-utils.c
branches/rawstudio-ng-color/librawstudio/rs-utils.h
branches/rawstudio-ng-color/src/rs-library.c
branches/rawstudio-ng-color/src/rs-store.c
Log:
Changed rs_normalize_path() to allocate memory from the heap.
Modified: branches/rawstudio-ng-color/librawstudio/rs-utils.c
===================================================================
--- branches/rawstudio-ng-color/librawstudio/rs-utils.c 2010-01-28 17:34:38 UTC
(rev 3108)
+++ branches/rawstudio-ng-color/librawstudio/rs-utils.c 2010-01-28 17:48:34 UTC
(rev 3109)
@@ -676,10 +676,23 @@
}
gchar *
-rs_normalize_path(gchar *path)
+rs_normalize_path(const gchar *path)
{
- char temp [PATH_MAX+1];
- return realpath(path, temp);
+#ifdef PATH_MAX
+ gint path_max = PATH_MAX;
+#else
+ gint path_max = pathconf(path, _PC_PATH_MAX);
+ if (path_max <= 0)
+ path_max = 4096;
+#endif
+ gchar *buffer = g_new0(gchar, path_max);
+
+ gchar *ret = realpath(path, buffer);
+
+ if (ret == NULL)
+ g_free(buffer);
+
+ return ret;
}
/**
Modified: branches/rawstudio-ng-color/librawstudio/rs-utils.h
===================================================================
--- branches/rawstudio-ng-color/librawstudio/rs-utils.h 2010-01-28 17:34:38 UTC
(rev 3108)
+++ branches/rawstudio-ng-color/librawstudio/rs-utils.h 2010-01-28 17:48:34 UTC
(rev 3109)
@@ -165,7 +165,7 @@
const gchar * rs_human_aperture(gdouble aperture);
const gchar * rs_human_focal(gdouble min, gdouble max);
-gchar * rs_normalize_path(gchar *path);
+gchar * rs_normalize_path(const gchar *path);
/**
* Copy a file from one location to another
Modified: branches/rawstudio-ng-color/src/rs-library.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-library.c 2010-01-28 17:34:38 UTC
(rev 3108)
+++ branches/rawstudio-ng-color/src/rs-library.c 2010-01-28 17:48:34 UTC
(rev 3109)
@@ -196,7 +196,7 @@
while (sqlite3_step(stmt) == SQLITE_ROW)
{
id = (gint) sqlite3_column_int(stmt, 0);
- filename = g_strdup(rs_normalize_path((gchar *)
sqlite3_column_text(stmt, 1)));
+ filename = rs_normalize_path((gchar *)
sqlite3_column_text(stmt, 1));
if (filename) /* FIXME: This will only work for
paths that exists */
{
rc = sqlite3_prepare_v2(db, "update
library set filename = ?1 WHERE id = ?2;", -1, &stmt_update, NULL);
@@ -1177,7 +1177,7 @@
{
val = xmlGetProp(cur, BAD_CAST "name");
temp = g_build_filename(directory, val, NULL);
- filename = g_strdup(rs_normalize_path(temp));
+ filename = rs_normalize_path(temp);
g_free(temp);
xmlFree(val);
Modified: branches/rawstudio-ng-color/src/rs-store.c
===================================================================
--- branches/rawstudio-ng-color/src/rs-store.c 2010-01-28 17:34:38 UTC (rev
3108)
+++ branches/rawstudio-ng-color/src/rs-store.c 2010-01-28 17:48:34 UTC (rev
3109)
@@ -1084,7 +1084,7 @@
continue;
gchar *temp = g_build_filename(path, name, NULL);
- fullname = g_strdup(rs_normalize_path(temp));
+ fullname = rs_normalize_path(temp);
g_free(temp);
if (rs_filetype_can_load(fullname))
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit