[gitg] Portability: replace PATH_MAX sized array with dynamic strings



commit 0a1ecf718f645b0bff54c86031007a5e133731ef
Author: Guilhem Bonnefille <guilhem bonnefille gmail com>
Date:   Sat Apr 18 10:29:16 2009 +0200

    Portability: replace PATH_MAX sized array with dynamic strings
    
    PATH_MAX is not so portable.
    Check http://www.debian.org/ports/hurd/hurd-devel-debian

 gitg/gitg-dirs.c        |    6 ++++--
 gitg/gitg-preferences.c |   12 ++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/gitg/gitg-dirs.c b/gitg/gitg-dirs.c
index 87db6eb..d255abf 100644
--- a/gitg/gitg-dirs.c
+++ b/gitg/gitg-dirs.c
@@ -23,7 +23,7 @@
 #include "gitg-dirs.h"
 #include "config.h"
 
-static gchar executable_directory[PATH_MAX]; 
+static gchar *executable_directory = NULL; 
 
 gchar const *
 gitg_dirs_get_data_dir()
@@ -33,6 +33,7 @@ gitg_dirs_get_data_dir()
 	if (!datadir)
 	{
 #ifdef ENABLE_BUNDLE
+		// FIXME ensure executable_directory is not NULL
 		gchar *up = g_path_get_dirname(executable_directory);
 		datadir = g_build_filename(up, "resources", NULL);
 		g_free(up);
@@ -82,6 +83,7 @@ gitg_dirs_initialize(int argc, char **argv)
 		g_free(cwd);
 	}
 
-	g_snprintf(executable_directory, PATH_MAX, "%s", path);
+	g_free(executable_directory);
+	executable_directory = g_strdup(path);
 	g_free(path);
 }
diff --git a/gitg/gitg-preferences.c b/gitg/gitg-preferences.c
index 63e1cab..6b93c09 100644
--- a/gitg/gitg-preferences.c
+++ b/gitg/gitg-preferences.c
@@ -92,8 +92,8 @@ static void on_preference_changed(GConfClient *client, guint id, GConfEntry *ent
 
 struct _Binding
 {
-	gchar key[PATH_MAX];
-	gchar property[PATH_MAX];
+	gchar *key;
+	gchar *property;
 
 	WrapGet wrap_get;
 	WrapSet wrap_set;
@@ -208,8 +208,8 @@ static void
 install_property_binding(guint prop_id, gchar const *group, gchar const *name, WrapGet wrap_get, WrapSet wrap_set)
 {
 	Binding *b = &property_bindings[prop_id];
-
-	g_snprintf(b->key, PATH_MAX, "%s/%s/%s", KEY_ROOT, group, name);
+	
+	b->key = g_strdup_printf("%s/%s/%s", KEY_ROOT, group, name);
 
 	gchar const *prefix = g_utf8_strrchr(group, -1, '/');
 
@@ -221,8 +221,8 @@ install_property_binding(guint prop_id, gchar const *group, gchar const *name, W
 	{
 		prefix = group;
 	}
-
-	g_snprintf(b->property, PATH_MAX, "%s-%s", prefix, name);
+	
+	b->property = g_strdup_printf("%s-%s", prefix, name);
 
 	b->wrap_get = wrap_get;
 	b->wrap_set = wrap_set;



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