..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:
Timo Sirainen 2000-12-02 07:08:49 +00:00 committed by cras
commit cfd50ce9cd
4 changed files with 21 additions and 25 deletions

View file

@ -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;
}