Bug 658772: Directory paths for resource directories are hard coded.

Corrected formatting to match coding standards; introduced local statics
to prevent leaking returned strings.
This commit is contained in:
John Ralls
2011-10-14 16:39:37 -07:00
parent a95c4c1bb4
commit 1db5b34b97

View File

@ -321,7 +321,10 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
static gchar *
get_bundle_path ()
{
gchar *base, *path;
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];
@ -332,44 +335,60 @@ get_bundle_path()
path = strdup (resource_path);
g_free (resource_path);
g_free (base);
}
return path;
}
const gchar *
_gtk_get_datadir (void)
{
static gchar *path = NULL;
if (path == NULL)
{
gchar *resource_dir = get_bundle_path ();
gchar *retval = g_build_filename(resource_dir, "share", NULL);
path = g_build_filename (resource_dir, "share", NULL);
g_free (resource_dir);
return retval;
}
return path;
}
const gchar *
_gtk_get_libdir (void)
{
static gchar *path = NULL;
if (path == NULL)
{
gchar *resource_dir = get_bundle_path ();
gchar *retval = g_build_filename(resource_dir, "lib", NULL);
path = g_build_filename (resource_dir, "lib", NULL);
g_free (resource_dir);
return retval;
}
return path;
}
const gchar *
_gtk_get_localedir (void)
{
static gchar *path = NULL;
if (path == NULL)
{
gchar *resource_dir = get_bundle_path ();
gchar *retval = g_build_filename(resource_dir, "share", "locale", NULL);
path = g_build_filename (resource_dir, "share", "locale", NULL);
g_free (resource_dir);
return retval;
}
return path;
}
const gchar *
_gtk_get_sysconfdir (void)
{
static gchar *path = NULL;
if (path == NULL)
{
gchar *resource_dir = get_bundle_path ();
gchar *retval = g_build_filename(resource_dir, "etc", NULL);
path = g_build_filename (resource_dir, "etc", NULL);
g_free (resource_dir);
return retval;
}
return path;
}
const gchar *