summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_prefix.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-06-07 01:33:43 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-06-09 10:16:24 +0100
commit0ab3575f700f961ba89a9477f010ca97294a0cf7 (patch)
tree31a96f31d987053b0b9fe02147b35af3d620fab9 /src/lib/eina/eina_prefix.c
parent3f26662390c625c94cea2bccd612a988031ad7c2 (diff)
eina - prefix - use smaller buffers for building strings
use less stack space but no features as buffers are big enough for all content used or alloca'd now.
Diffstat (limited to '')
-rw-r--r--src/lib/eina/eina_prefix.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/eina/eina_prefix.c b/src/lib/eina/eina_prefix.c
index dd483a085a..13b6e6d01d 100644
--- a/src/lib/eina/eina_prefix.c
+++ b/src/lib/eina/eina_prefix.c
@@ -301,8 +301,9 @@ _try_argv(Eina_Prefix *pfx, const char *argv0)
301 { 301 {
302 if (getcwd(buf2, sizeof(buf2))) 302 if (getcwd(buf2, sizeof(buf2)))
303 { 303 {
304 char joined[PATH_MAX]; 304 size_t len = strlen(buf2) + 1 + strlen(argv0) + 1;
305 eina_file_path_join(joined, sizeof(joined), buf2, argv0); 305 char *joined = alloca(len);
306 eina_file_path_join(joined, len, buf2, argv0);
306 if (realpath(joined, buf)) 307 if (realpath(joined, buf))
307 { 308 {
308 if (access(buf, X_OK) == 0) 309 if (access(buf, X_OK) == 0)
@@ -371,7 +372,7 @@ _try_argv(Eina_Prefix *pfx, const char *argv0)
371static int 372static int
372_get_env_var(char **var, const char *envprefix, const char *envsuffix, const char *prefix, const char *dir) 373_get_env_var(char **var, const char *envprefix, const char *envsuffix, const char *prefix, const char *dir)
373{ 374{
374 char env[1024]; 375 char env[64];
375 const char *s; 376 const char *s;
376 377
377#if defined(HAVE_GETUID) && defined(HAVE_GETEUID) 378#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
@@ -387,8 +388,11 @@ _get_env_var(char **var, const char *envprefix, const char *envsuffix, const cha
387 } 388 }
388 else if (prefix) 389 else if (prefix)
389 { 390 {
390 char buf[PATH_MAX]; 391 size_t len = strlen(prefix) + 1 + strlen(dir) + 1;
391 eina_file_path_join(buf, sizeof(buf), prefix, dir); 392 char *buf;
393
394 buf = alloca(len);
395 eina_file_path_join(buf, len, prefix, dir);
392 INF("Have %s_PREFIX = %s, use %s = %s", envprefix, prefix, env, buf); 396 INF("Have %s_PREFIX = %s, use %s = %s", envprefix, prefix, env, buf);
393 STRDUP_REP(*var, buf); 397 STRDUP_REP(*var, buf);
394 return 1; 398 return 1;
@@ -409,7 +413,7 @@ _get_env_vars(Eina_Prefix *pfx,
409 const char *datadir, 413 const char *datadir,
410 const char *localedir) 414 const char *localedir)
411{ 415{
412 char env[1024]; 416 char env[32];
413 const char *prefix; 417 const char *prefix;
414 int ret = 0; 418 int ret = 0;
415 419