]> git.saurik.com Git - bison.git/commitdiff
* configure.in: Invoke AM_LIB_DMALLOC.
authorAkim Demaille <akim@epita.fr>
Sat, 22 Sep 2001 17:19:03 +0000 (17:19 +0000)
committerAkim Demaille <akim@epita.fr>
Sat, 22 Sep 2001 17:19:03 +0000 (17:19 +0000)
* src/system.h: Use dmalloc.
* src/LR0.c: Be sure to have pointers initialized to NULL.
(allocate_itemsets): Allocate kernel_items only if needed.

ChangeLog
Makefile.in
aclocal.m4
config.hin
configure
configure.in
m4/Makefile.am
m4/Makefile.in
m4/dmalloc.m4 [new file with mode: 0644]
src/LR0.c
src/system.h

index 0823b5aaf36e7345de5893b201f5895a9530a625..6512f08fb91dceaf39dcf565f0af12cfad02ed7a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
index 7daeea720a3fb36b87d503e38738ffcf134e0177..e053875a849ed753533e1af60dc9f33ed6c33ea9 100644 (file)
@@ -153,7 +153,7 @@ $(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 $(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 \
index e3c6c4a739fe18922854496030f36f5c17e2bb6a..01cda9d2f8832bd2f19d2fc2be97bc72ec6e6446 100644 (file)
@@ -937,6 +937,25 @@ if test $ac_cv_func_strerror_r = yes; 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.
 #
index 5f926faabfed927af10c407a99c43db4846d4d2f..b38aa38701889a50f21c98ff24b8d203abf9b561 100644 (file)
 /* 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
 
index 7ada1a96e14e4e30623afa308009ca78303f1a89..44fad5bd91baa3d9da054825beecf111fbac91ac 100755 (executable)
--- a/configure
+++ b/configure
@@ -739,6 +739,8 @@ Optional Features:
 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
 
@@ -6619,6 +6621,31 @@ _ACEOF
   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 ||
index 548f3a98dfac2a8d67f3a736dbbc6cca74fe6ee3..db2d5a736be6b440877c03871434e1e3d3142785 100644 (file)
@@ -88,6 +88,7 @@ jm_FUNC_MALLOC
 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
index 3ed90aa47a0f1b7c0e6e25c088b5535a9bdc9f06..a476511cf08d04388b090e36d2a962de728980fd 100644 (file)
@@ -2,6 +2,7 @@
 EXTRA_DIST =                                   \
 c-bs-a.m4                                      \
 codeset.m4                                     \
+dmalloc.m4                                     \
 error.m4                                       \
 gettext.m4                                     \
 glibc21.m4                                     \
index 40e050d6c5be9b32d5646c749f17a157efce2546..479108ffe2d9e954cf0b22151694f6b5f5ce095b 100644 (file)
@@ -99,6 +99,7 @@ install_sh = @install_sh@
 EXTRA_DIST = \
 c-bs-a.m4                                      \
 codeset.m4                                     \
+dmalloc.m4                                     \
 error.m4                                       \
 gettext.m4                                     \
 glibc21.m4                                     \
diff --git a/m4/dmalloc.m4 b/m4/dmalloc.m4
new file mode 100644 (file)
index 0000000..f724670
--- /dev/null
@@ -0,0 +1,22 @@
+## ----------------------------------- ##
+## 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)])
+])
index b37594e6d47debe94a5a8e70ce88dd8c8638abd6..644d2644415f91aa223754cfceed078366f33db5 100644 (file)
--- a/src/LR0.c
+++ b/src/LR0.c
 
 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);
@@ -89,7 +89,8 @@ allocate_itemsets (void)
      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++)
index f57247897e84dc15c12e301de369472de53d58a6..5d15969ab7fe13018de3a36a7d69eef19229f10d 100644 (file)
@@ -143,8 +143,6 @@ size_t strnlen PARAMS ((const char *s, size_t maxlen));
 # define LOCALEDIR "/usr/local/share/locale"
 #endif
 
-#endif  /* BISON_SYSTEM_H */
-
 
 /*-----------.
 | Booleans.  |
@@ -264,3 +262,17 @@ do {                                                               \
 #  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 */