* src/system.h: Use dmalloc.
* src/LR0.c: Be sure to have pointers initialized to NULL.
(allocate_itemsets): Allocate kernel_items only if needed.
+2001-09-22 Akim Demaille <akim@epita.fr>
+
+ * configure.in: Invoke AM_LIB_DMALLOC.
+ * src/system.h: Use dmalloc.
+ * src/LR0.c: Be sure to have pointers initialized to NULL.
+ (allocate_itemsets): Allocate kernel_items only if needed.
+
2001-09-22 Akim Demaille <akim@epita.fr>
* configure.in: Bump to 1.29b.
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4): configure.in m4/c-bs-a.m4 m4/codeset.m4 m4/error.m4 m4/gettext.m4 m4/glibc21.m4 m4/iconv.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/m4.m4 m4/malloc.m4 m4/mbstate_t.m4 m4/prereq.m4 m4/progtest.m4 m4/realloc.m4 m4/strerror_r.m4 m4/warning.m4
+$(ACLOCAL_M4): configure.in m4/c-bs-a.m4 m4/codeset.m4 m4/dmalloc.m4 m4/error.m4 m4/gettext.m4 m4/glibc21.m4 m4/iconv.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/m4.m4 m4/malloc.m4 m4/mbstate_t.m4 m4/prereq.m4 m4/progtest.m4 m4/realloc.m4 m4/strerror_r.m4 m4/warning.m4
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h
@if test ! -f $@; then \
fi
])# AC_FUNC_STRERROR_R
+
+# serial 1
+
+AC_DEFUN([AM_WITH_DMALLOC],
+[AC_MSG_CHECKING([if malloc debugging is wanted])
+AC_ARG_WITH(dmalloc,
+[ --with-dmalloc use dmalloc, as in
+ http://www.dmalloc.com/dmalloc.tar.gz],
+[if test "$withval" = yes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(WITH_DMALLOC,1,
+ [Define if using the dmalloc debugging malloc package])
+ LIBS="$LIBS -ldmalloc"
+ LDFLAGS="$LDFLAGS -g"
+else
+ AC_MSG_RESULT(no)
+fi], [AC_MSG_RESULT(no)])
+])
+
# Macro to add for using GNU gettext.
# Ulrich Drepper <drepper@cygnus.com>, 1995.
#
/* Version number of package */
#undef VERSION
+/* Define if using the dmalloc debugging malloc package */
+#undef WITH_DMALLOC
+
/* Define to 1 for GNU C library extensions. */
#undef _GNU_SOURCE
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-dmalloc use dmalloc, as in
+ http://www.dmalloc.com/dmalloc.tar.gz
--with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
--with-included-gettext use the GNU gettext library included here
fi
fi
+echo "$as_me:$LINENO: checking if malloc debugging is wanted" >&5
+echo $ECHO_N "checking if malloc debugging is wanted... $ECHO_C" >&6
+
+# Check whether --with-dmalloc or --without-dmalloc was given.
+if test "${with_dmalloc+set}" = set; then
+ withval="$with_dmalloc"
+ if test "$withval" = yes; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define WITH_DMALLOC 1
+_ACEOF
+
+ LIBS="$LIBS -ldmalloc"
+ LDFLAGS="$LDFLAGS -g"
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi;
+
ALL_LINGUAS="de es et fr ja nl tr ru"
# Make sure we can run config.sub.
$ac_config_sub sun4 >/dev/null 2>&1 ||
jm_FUNC_REALLOC
jm_PREREQ_QUOTEARG
jm_PREREQ_ERROR
+AM_WITH_DMALLOC
ALL_LINGUAS="de es et fr ja nl tr ru"
AM_GNU_GETTEXT
EXTRA_DIST = \
c-bs-a.m4 \
codeset.m4 \
+dmalloc.m4 \
error.m4 \
gettext.m4 \
glibc21.m4 \
EXTRA_DIST = \
c-bs-a.m4 \
codeset.m4 \
+dmalloc.m4 \
error.m4 \
gettext.m4 \
glibc21.m4 \
--- /dev/null
+## ----------------------------------- ##
+## Check if --with-dmalloc was given. ##
+## From Franc,ois Pinard ##
+## ----------------------------------- ##
+
+# serial 1
+
+AC_DEFUN([AM_WITH_DMALLOC],
+[AC_MSG_CHECKING([if malloc debugging is wanted])
+AC_ARG_WITH(dmalloc,
+[ --with-dmalloc use dmalloc, as in
+ http://www.dmalloc.com/dmalloc.tar.gz],
+[if test "$withval" = yes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(WITH_DMALLOC,1,
+ [Define if using the dmalloc debugging malloc package])
+ LIBS="$LIBS -ldmalloc"
+ LDFLAGS="$LDFLAGS -g"
+else
+ AC_MSG_RESULT(no)
+fi], [AC_MSG_RESULT(no)])
+])
int nstates;
int final_state;
-core *first_state;
-shifts *first_shift;
-reductions *first_reduction;
+core *first_state = NULL;
+shifts *first_shift = NULL;
+reductions *first_reduction = NULL;
-static core *this_state;
-static core *last_state;
-static shifts *last_shift;
-static reductions *last_reduction;
+static core *this_state = NULL;
+static core *last_state = NULL;
+static shifts *last_shift = NULL;
+static reductions *last_reduction = NULL;
static int nshifts;
-static short *shift_symbol;
+static short *shift_symbol = NULL;
-static short *redset;
-static short *shiftset;
+static short *redset = NULL;
+static short *shiftset = NULL;
-static short **kernel_base;
-static short **kernel_end;
-static short *kernel_items;
+static short **kernel_base = NULL;
+static short **kernel_end = NULL;
+static short *kernel_items = NULL;
/* hash table for states, to recognize equivalent ones. */
#define STATE_TABLE_SIZE 1009
-static core **state_table;
+static core **state_table = NULL;
\f
static void
allocate_itemsets (void)
{
- short *itemp;
+ short *itemp = NULL;
int symbol;
int i;
int count;
- short *symbol_count;
+ short *symbol_count = NULL;
count = 0;
symbol_count = XCALLOC (short, nsyms);
We allocate that much space for each symbol. */
kernel_base = XCALLOC (short *, nsyms);
- kernel_items = XCALLOC (short, count);
+ if (count)
+ kernel_items = XCALLOC (short, count);
count = 0;
for (i = 0; i < nsyms; i++)
# define LOCALEDIR "/usr/local/share/locale"
#endif
-#endif /* BISON_SYSTEM_H */
-
/*-----------.
| Booleans. |
# define BISON_HAIRY "c:/usr/local/lib/bison.hairy"
# endif
#endif
+
+
+/*---------------------------------.
+| Debugging the memory allocator. |
+`---------------------------------*/
+
+# if WITH_DMALLOC
+# define DMALLOC_FUNC_CHECK
+# include <dmalloc.h>
+
+# endif /* WITH_DMALLOC */
+
+
+#endif /* BISON_SYSTEM_H */