[PATCH 2 of 2] osutil.c: replace alloca() with malloc() and remove <alloca.h>
Giorgos Keramidas
keramida at ceid.upatras.gr
Sun Oct 7 19:00:31 UTC 2007
# HG changeset patch
# User Giorgos Keramidas <keramida at ceid.upatras.gr>
# Date 1191783522 -10800
# Node ID 5d13d2d3f42bc150f711bfa3a8bb38a7d0b5c1d4
# Parent 37dc732e00416a50dcc9b994961acdb6ceb755ba
osutil.c: replace alloca() with malloc() and remove <alloca.h>
The <alloca.h> header is not really portable, and it breaks Mercurial on
FreeBSD. Remove the dependency on <alloca.h> and alloca() by replacing
the only place where it was used with malloc().
diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -9,7 +9,6 @@
#define _ATFILE_SOURCE
#include <Python.h>
-#include <alloca.h>
#include <dirent.h>
#include <fcntl.h>
#include <string.h>
@@ -116,7 +115,7 @@ static PyObject *listdir(PyObject *self,
PyObject *list = NULL;
PyObject *ctor_args = NULL;
int all_kinds = 1;
- char *full_path;
+ char *full_path = NULL;
int path_len;
int do_stat;
char *path;
@@ -141,7 +140,7 @@ static PyObject *listdir(PyObject *self,
if ((list = PyList_New(0)) == NULL)
goto bail;
- full_path = alloca(path_len + PATH_MAX + 2);
+ full_path = malloc(path_len + PATH_MAX + 2);
memcpy(full_path, path, path_len);
full_path[path_len] = '/';
@@ -303,6 +302,7 @@ done:
if (dir)
closedir(dir);
+ free(full_path);
return list;
}
More information about the Mercurial-devel
mailing list