diff options
author | Timo Sirainen <cras@irssi.org> | 2000-12-02 07:08:49 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-12-02 07:08:49 +0000 |
commit | cfd50ce9cdbeab86ac5d25499f081326481584fc (patch) | |
tree | 6eda91182e7993b670225c44c6a99a5fd97b156e /src/lib-popt | |
parent | 32790f15151664d7869f4e898c833f1ede81c0f9 (diff) | |
download | irssi-cfd50ce9cdbeab86ac5d25499f081326481584fc.zip |
..and removed the rest of the alloca()s too
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@918 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/lib-popt')
-rw-r--r-- | src/lib-popt/findme.c | 14 | ||||
-rw-r--r-- | src/lib-popt/poptconfig.c | 14 | ||||
-rw-r--r-- | src/lib-popt/popthelp.c | 14 | ||||
-rw-r--r-- | src/lib-popt/poptparse.c | 4 |
4 files changed, 21 insertions, 25 deletions
diff --git a/src/lib-popt/findme.c b/src/lib-popt/findme.c index a465a051..fae8f032 100644 --- a/src/lib-popt/findme.c +++ b/src/lib-popt/findme.c @@ -10,10 +10,6 @@ #include <libc.h> #endif -#if HAVE_ALLOCA_H -# include <alloca.h> -#endif - #include "findme.h" char * findProgramPath(char * argv0) { @@ -29,9 +25,8 @@ char * findProgramPath(char * argv0) { if (!path) return NULL; - start = pathbuf = alloca(strlen(path) + 1); - buf = malloc(strlen(path) + strlen(argv0) + 2); - strcpy(pathbuf, path); + start = pathbuf = g_strdup(path); + buf = g_malloc(strlen(path) + strlen(argv0) + 2); chptr = NULL; do { @@ -40,8 +35,10 @@ char * findProgramPath(char * argv0) { sprintf(buf, "%s/%s", start, argv0); #ifndef WIN32 - if (!access(buf, X_OK)) + if (!access(buf, X_OK)) { + g_free(pathbuf); return buf; + } #endif if (chptr) @@ -50,6 +47,7 @@ char * findProgramPath(char * argv0) { start = NULL; } while (start && *start); + g_free(pathbuf); free(buf); return NULL; diff --git a/src/lib-popt/poptconfig.c b/src/lib-popt/poptconfig.c index 9219e9bf..d064297c 100644 --- a/src/lib-popt/poptconfig.c +++ b/src/lib-popt/poptconfig.c @@ -4,10 +4,6 @@ #include "common.h" -#if HAVE_ALLOCA_H -# include <alloca.h> -#endif - #include "popt.h" #include "poptint.h" @@ -77,16 +73,17 @@ int poptReadConfigFile(poptContext con, char * fn) { fileLength = lseek(fd, 0, SEEK_END); lseek(fd, 0, 0); - file = alloca(fileLength + 1); + file = malloc(fileLength + 1); if (read(fd, file, fileLength) != fileLength) { rc = errno; close(fd); errno = rc; + free(file); return POPT_ERROR_ERRNO; } close(fd); - dst = buf = alloca(fileLength + 1); + dst = buf = malloc(fileLength + 1); chptr = file; end = (file + fileLength); @@ -116,6 +113,8 @@ int poptReadConfigFile(poptContext con, char * fn) { } } + free(buf); + free(file); return 0; } @@ -132,10 +131,11 @@ int poptReadDefaultConfig(poptContext con, int useEnv) { #endif if ((home = getenv("HOME"))) { - fn = alloca(strlen(home) + 20); + fn = malloc(strlen(home) + 20); strcpy(fn, home); strcat(fn, "/.popt"); rc = poptReadConfigFile(con, fn); + free(fn); if (rc) return rc; } diff --git a/src/lib-popt/popthelp.c b/src/lib-popt/popthelp.c index 7d1567c4..493726e0 100644 --- a/src/lib-popt/popthelp.c +++ b/src/lib-popt/popthelp.c @@ -6,10 +6,6 @@ #include "common.h" -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif - #include "popt.h" #include "poptint.h" @@ -66,7 +62,7 @@ static void singleOptionHelp(FILE * f, int maxLeftCol, int helpLength; const char * ch; char format[10]; - char * left = alloca(maxLeftCol + 1); + char * left = malloc(maxLeftCol + 1); const char * argDescrip = getArgDescrip(opt, translation_domain); *left = '\0'; @@ -76,7 +72,10 @@ static void singleOptionHelp(FILE * f, int maxLeftCol, sprintf(left, "-%c", opt->shortName); else if (opt->longName) sprintf(left, "--%s", opt->longName); - if (!*left) return ; + if (!*left) { + free(left); + return; + } if (argDescrip) { strcat(left, "="); strcat(left, argDescrip); @@ -86,9 +85,12 @@ static void singleOptionHelp(FILE * f, int maxLeftCol, fprintf(f," %-*s ", maxLeftCol, left); else { fprintf(f," %s\n", left); + free(left); return; } + free(left); + helpLength = strlen(help); while (helpLength > lineLength) { ch = help + lineLength - 1; diff --git a/src/lib-popt/poptparse.c b/src/lib-popt/poptparse.c index 6e412834..eb2a6721 100644 --- a/src/lib-popt/poptparse.c +++ b/src/lib-popt/poptparse.c @@ -10,10 +10,6 @@ #include <stdlib.h> #include <string.h> -#ifdef HAVE_ALLOCA_H -#include <alloca.h> -#endif - #include "popt.h" static const int poptArgvArrayGrowDelta = 5; |