[babl] fish_cache_path(): simplify through use stack instead of heap
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] fish_cache_path(): simplify through use stack instead of heap
- Date: Sun, 20 Nov 2016 21:40:29 +0000 (UTC)
commit 31acaf49dd5f087fa2449037c7197f07f21894ee
Author: Øyvind Kolås <pippin gimp org>
Date: Sun Nov 20 22:39:05 2016 +0100
fish_cache_path(): simplify through use stack instead of heap
babl/babl-cache.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/babl/babl-cache.c b/babl/babl-cache.c
index 0ef3f83..e0c9365 100644
--- a/babl/babl-cache.c
+++ b/babl/babl-cache.c
@@ -47,10 +47,12 @@ mk_ancestry_iter (const char *path)
}
static void
-mk_ancestry (char *path)
+mk_ancestry (const char *path)
{
+ char copy[4096];
+ strncpy (copy, path, 4096);
#ifdef _WIN32
- for (char *c = path; *c; c++)
+ for (char *c = copy; *c; c++)
if (*c == '\\')
*c = '/';
#endif
@@ -61,7 +63,6 @@ static const char *fish_cache_path (void)
{
struct stat stat_buf;
static char resolved[4096];
- char *ret = NULL;
#ifndef _WIN32
if (getenv ("HOME"))
@@ -78,10 +79,7 @@ static const char *fish_cache_path (void)
if (stat (resolved, &stat_buf)==0 && S_ISREG(stat_buf.st_mode))
return resolved;
- ret = strdup (resolved);
- mk_ancestry (ret);
- strcpy (resolved, ret);
- free (ret);
+ mk_ancestry (resolved);
return resolved;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]