aboutsummaryrefslogtreecommitdiff
path: root/src/util/os_installation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-12-04 12:48:32 +0000
committerChristian Grothoff <christian@grothoff.org>2013-12-04 12:48:32 +0000
commit0af5bbb1101d64b98a4b6a67e17c98654e794161 (patch)
treef5a3790b90e13992e7fc712758a005bf6477889c /src/util/os_installation.c
parent6ed6289b5400ba9359827d8a9b93c4496a27e86f (diff)
downloadgnunet-0af5bbb1101d64b98a4b6a67e17c98654e794161.tar.gz
gnunet-0af5bbb1101d64b98a4b6a67e17c98654e794161.zip
-reduce stat calls by caching result of GNUNET_OS_installation_get_path
Diffstat (limited to 'src/util/os_installation.c')
-rw-r--r--src/util/os_installation.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index a94798d8d..30e729dc6 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -627,21 +627,24 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind)
627char * 627char *
628GNUNET_OS_get_libexec_binary_path (const char *progname) 628GNUNET_OS_get_libexec_binary_path (const char *progname)
629{ 629{
630 static char *cache;
630 char *libexecdir; 631 char *libexecdir;
631 char *binary; 632 char *binary;
632 633
633 if (DIR_SEPARATOR == progname[0]) 634 if ( (DIR_SEPARATOR == progname[0]) ||
635 (GNUNET_YES == GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL)) )
634 return GNUNET_strdup (progname); 636 return GNUNET_strdup (progname);
635 if (GNUNET_YES == GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL)) 637 if (NULL != cache)
636 return GNUNET_strdup (progname); 638 libexecdir = cache;
637 libexecdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR); 639 else
640 libexecdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR);
638 if (NULL == libexecdir) 641 if (NULL == libexecdir)
639 return GNUNET_strdup (progname); 642 return GNUNET_strdup (progname);
640 GNUNET_asprintf (&binary, 643 GNUNET_asprintf (&binary,
641 "%s%s", 644 "%s%s",
642 libexecdir, 645 libexecdir,
643 progname); 646 progname);
644 GNUNET_free (libexecdir); 647 cache = libexecdir;
645 return binary; 648 return binary;
646} 649}
647 650