forked from PsychoticNinja/irssi
..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
This commit is contained in:
parent
32790f1515
commit
cfd50ce9cd
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user