summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-01-23 20:13:42 +0000
committerJim Meyering <jim@meyering.net>2003-01-23 20:13:42 +0000
commit89beded7d0583a23343198acef704a24df844dcd (patch)
treef2fb9644458c45705b40f73faef0e62d6bd3d952 /lib
parent07dad3b45de28aab372a7dc0daf83ee326490f20 (diff)
downloadcoreutils-89beded7d0583a23343198acef704a24df844dcd.tar.xz
[HAVE_CONFIG_H]: Include <config.h>.
Add autoconf-recommended block of alloca-related code. Cast each use of alloca to the required type, (node**).
Diffstat (limited to 'lib')
-rw-r--r--lib/tsearch.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/tsearch.c b/lib/tsearch.c
index 12d6a49a4..82bb09474 100644
--- a/lib/tsearch.c
+++ b/lib/tsearch.c
@@ -84,6 +84,24 @@
In this case, A has been rotated left. This preserves the ordering of the
binary tree. */
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if __GNUC__
+# define alloca __builtin_alloca
+#else
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ # pragma alloca
+# else
+char *alloca ();
+# endif
+# endif
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <search.h>
@@ -360,7 +378,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
would need to have around 250.000 nodes. */
int stacksize = 40;
int sp = 0;
- node **nodestack = alloca (sizeof (node *) * stacksize);
+ node **nodestack = (node **) alloca (sizeof (node *) * stacksize);
if (rootp == NULL)
return NULL;
@@ -376,7 +394,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
{
node **newstack;
stacksize += 20;
- newstack = alloca (sizeof (node *) * stacksize);
+ newstack = (node **) alloca (sizeof (node *) * stacksize);
nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
}
@@ -414,7 +432,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
{
node **newstack;
stacksize += 20;
- newstack = alloca (sizeof (node *) * stacksize);
+ newstack = (node **) alloca (sizeof (node *) * stacksize);
nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
}
nodestack[sp++] = parent;