[libgsystem] fileutil: avoid using PATH_MAX
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] fileutil: avoid using PATH_MAX
- Date: Tue, 15 Jul 2014 20:34:07 +0000 (UTC)
commit de2619271ee3ab42971fc770cae110f23e330c30
Author: Andreas Henriksson <andreas henriksson endian se>
Date: Tue Jul 15 20:34:15 2014 +0200
fileutil: avoid using PATH_MAX
Use the dynamically allocated buffer returned by realpath instead of
using PATH_MAX which is not defined on platforms like Hurd.
src/gsystem-file-utils.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/gsystem-file-utils.c b/src/gsystem-file-utils.c
index 6a35ed7..c157d1d 100644
--- a/src/gsystem-file-utils.c
+++ b/src/gsystem-file-utils.c
@@ -1363,18 +1363,23 @@ GFile *
gs_file_realpath (GFile *file)
{
gchar *path;
- gchar path_real[PATH_MAX];
+ char *path_real;
+ GFile *file_real;
path = g_file_get_path (file);
- if (realpath ((const char *) path, path_real) == NULL)
+ path_real = realpath((const char *) path, NULL);
+ if (path_real == NULL)
{
g_free (path);
return NULL;
}
g_free (path);
- return g_file_new_for_path (path_real);
+ file_real = g_file_new_for_path (path_real);
+ free (path_real);
+
+ return file_real;
}
#ifdef GSYSTEM_CONFIG_XATTRS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]