summaryrefslogtreecommitdiff
path: root/gtk/gtkquartz.c
diff options
context:
space:
mode:
authorJohn Ralls <jralls@ceridwen.us>2011-10-14 16:39:37 -0700
committerJohn Ralls <jralls@ceridwen.us>2011-10-15 12:41:53 -0700
commit1db5b34b97395b581a147fa4dad7a1a9872b8b67 (patch)
tree39d9fed212d9def5a1108ce16718fc758e408265 /gtk/gtkquartz.c
parenta95c4c1bb46d893e0066503183b6bbeedfb370e3 (diff)
downloadgtk+-1db5b34b97395b581a147fa4dad7a1a9872b8b67.tar.gz
Bug 658772: Directory paths for resource directories are hard coded.
Corrected formatting to match coding standards; introduced local statics to prevent leaking returned strings.
Diffstat (limited to 'gtk/gtkquartz.c')
-rw-r--r--gtk/gtkquartz.c79
1 files changed, 49 insertions, 30 deletions
diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
index e15890e7ed..771309c55e 100644
--- a/gtk/gtkquartz.c
+++ b/gtk/gtkquartz.c
@@ -319,62 +319,81 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
*/
static gchar *
-get_bundle_path()
+get_bundle_path ()
{
- gchar *base, *path;
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- gchar *resource_path = g_strdup([[[NSBundle mainBundle] resourcePath] UTF8String]);
- [pool drain];
- base = g_path_get_basename(resource_path);
- if (strcmp(base, "bin") == 0)
- path = g_path_get_dirname(resource_path);
- else
- path = strdup(resource_path);
- g_free(resource_path);
- g_free(base);
+ static gchar *path = NULL;
+ if (path == NULL)
+ {
+ gchar *base;
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ gchar *resource_path = g_strdup ([[[NSBundle mainBundle] resourcePath] UTF8String]);
+ [pool drain];
+ base = g_path_get_basename (resource_path);
+ if (strcmp (base, "bin") == 0)
+ path = g_path_get_dirname (resource_path);
+ else
+ path = strdup (resource_path);
+ g_free (resource_path);
+ g_free (base);
+ }
return path;
}
const gchar *
_gtk_get_datadir (void)
{
- gchar *resource_dir = get_bundle_path();
- gchar *retval = g_build_filename(resource_dir, "share", NULL);
- g_free(resource_dir);
- return retval;
+ static gchar *path = NULL;
+ if (path == NULL)
+ {
+ gchar *resource_dir = get_bundle_path ();
+ path = g_build_filename (resource_dir, "share", NULL);
+ g_free (resource_dir);
+ }
+ return path;
}
const gchar *
_gtk_get_libdir (void)
{
- gchar *resource_dir = get_bundle_path();
- gchar *retval = g_build_filename(resource_dir, "lib", NULL);
- g_free(resource_dir);
- return retval;
+ static gchar *path = NULL;
+ if (path == NULL)
+ {
+ gchar *resource_dir = get_bundle_path ();
+ path = g_build_filename (resource_dir, "lib", NULL);
+ g_free (resource_dir);
+ }
+ return path;
}
const gchar *
_gtk_get_localedir (void)
{
-
- gchar *resource_dir = get_bundle_path();
- gchar *retval = g_build_filename(resource_dir, "share", "locale", NULL);
- g_free(resource_dir);
- return retval;
+ static gchar *path = NULL;
+ if (path == NULL)
+ {
+ gchar *resource_dir = get_bundle_path ();
+ path = g_build_filename (resource_dir, "share", "locale", NULL);
+ g_free (resource_dir);
+ }
+ return path;
}
const gchar *
_gtk_get_sysconfdir (void)
{
- gchar *resource_dir = get_bundle_path();
- gchar *retval = g_build_filename(resource_dir, "etc", NULL);
- g_free(resource_dir);
- return retval;
+ static gchar *path = NULL;
+ if (path == NULL)
+ {
+ gchar *resource_dir = get_bundle_path ();
+ path = g_build_filename (resource_dir, "etc", NULL);
+ g_free (resource_dir);
+ }
+ return path;
}
const gchar *
_gtk_get_data_prefix (void)
{
- return get_bundle_path();
+ return get_bundle_path ();
}