ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
July 17th, 2024 | 10:00am-11:55am SGT (UTC+8) | Online

Ethereal-dev: [Ethereal-dev] Portable use of alloca()

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Albert Chin <ethereal-dev@xxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Sep 2003 11:19:50 -0500
Use of alloca() differs depending on platform. Stolen from Proftpd's
lib/glibc-glob.c file which is under the LGPL.

Against 0.9.15.

-- 
albert chin (china@xxxxxxxxxxxxxxxxxx)

-- snip snip
--- configure.in.orig	Wed Sep 10 10:11:55 2003
+++ configure.in	Wed Sep 10 10:12:08 2003
@@ -725,6 +630,8 @@
 
 AC_CHECK_FUNCS(getprotobynumber gethostbyname2)
 
+AC_FUNC_ALLOCA
+
 dnl blank for now, but will be used in future
 AC_SUBST(ethereal_SUBDIRS)
 
--- packet-lwapp.c.orig	Wed Sep 10 10:21:23 2003
+++ packet-lwapp.c	Wed Sep 10 10:21:46 2003
@@ -26,6 +26,10 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#if defined _AIX && !defined __GNUC__
+ #pragma alloca
+#endif
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -46,6 +50,19 @@
 #ifdef NEED_SNPRINTF_H
 # include "snprintf.h"
 #endif
+
+/* Make alloca work the best possible way.  */
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not __GNUC__ */
+#if HAVE_ALLOCA_H
+#include <alloca.h>
+#else /* not __GNUC__ or HAVE_ALLOCA_H */
+#ifndef _AIX /* Already did AIX, up at the top.  */
+char *alloca ();
+#endif /* not _AIX */
+#endif /* not HAVE_ALLOCA_H */
+#endif /* not __GNUC__ */
 
 #define LWAPP_FLAGS_T 0x04
 #define LWAPP_FLAGS_F 0x02