* 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.
This commit is contained in:
Akim Demaille
2001-09-22 17:19:03 +00:00
parent 19f01e885f
commit f2632e420f
11 changed files with 114 additions and 20 deletions

View File

@@ -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> 2001-09-22 Akim Demaille <akim@epita.fr>
* configure.in: Bump to 1.29b. * configure.in: Bump to 1.29b.

View File

@@ -153,7 +153,7 @@ $(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF) 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) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h config.h: stamp-h
@if test ! -f $@; then \ @if test ! -f $@; then \

19
aclocal.m4 vendored
View File

@@ -937,6 +937,25 @@ if test $ac_cv_func_strerror_r = yes; then
fi fi
])# AC_FUNC_STRERROR_R ])# 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. # Macro to add for using GNU gettext.
# Ulrich Drepper <drepper@cygnus.com>, 1995. # Ulrich Drepper <drepper@cygnus.com>, 1995.
# #

View File

@@ -250,6 +250,9 @@
/* Version number of package */ /* Version number of package */
#undef VERSION #undef VERSION
/* Define if using the dmalloc debugging malloc package */
#undef WITH_DMALLOC
/* Define to 1 for GNU C library extensions. */ /* Define to 1 for GNU C library extensions. */
#undef _GNU_SOURCE #undef _GNU_SOURCE

27
configure vendored
View File

@@ -739,6 +739,8 @@ Optional Features:
Optional Packages: Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --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-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
--with-included-gettext use the GNU gettext library included here --with-included-gettext use the GNU gettext library included here
@@ -6619,6 +6621,31 @@ _ACEOF
fi fi
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" ALL_LINGUAS="de es et fr ja nl tr ru"
# Make sure we can run config.sub. # Make sure we can run config.sub.
$ac_config_sub sun4 >/dev/null 2>&1 || $ac_config_sub sun4 >/dev/null 2>&1 ||

View File

@@ -88,6 +88,7 @@ jm_FUNC_MALLOC
jm_FUNC_REALLOC jm_FUNC_REALLOC
jm_PREREQ_QUOTEARG jm_PREREQ_QUOTEARG
jm_PREREQ_ERROR jm_PREREQ_ERROR
AM_WITH_DMALLOC
ALL_LINGUAS="de es et fr ja nl tr ru" ALL_LINGUAS="de es et fr ja nl tr ru"
AM_GNU_GETTEXT AM_GNU_GETTEXT

View File

@@ -2,6 +2,7 @@
EXTRA_DIST = \ EXTRA_DIST = \
c-bs-a.m4 \ c-bs-a.m4 \
codeset.m4 \ codeset.m4 \
dmalloc.m4 \
error.m4 \ error.m4 \
gettext.m4 \ gettext.m4 \
glibc21.m4 \ glibc21.m4 \

View File

@@ -99,6 +99,7 @@ install_sh = @install_sh@
EXTRA_DIST = \ EXTRA_DIST = \
c-bs-a.m4 \ c-bs-a.m4 \
codeset.m4 \ codeset.m4 \
dmalloc.m4 \
error.m4 \ error.m4 \
gettext.m4 \ gettext.m4 \
glibc21.m4 \ glibc21.m4 \

22
m4/dmalloc.m4 Normal file
View File

@@ -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)])
])

View File

@@ -33,39 +33,39 @@
int nstates; int nstates;
int final_state; int final_state;
core *first_state; core *first_state = NULL;
shifts *first_shift; shifts *first_shift = NULL;
reductions *first_reduction; reductions *first_reduction = NULL;
static core *this_state; static core *this_state = NULL;
static core *last_state; static core *last_state = NULL;
static shifts *last_shift; static shifts *last_shift = NULL;
static reductions *last_reduction; static reductions *last_reduction = NULL;
static int nshifts; static int nshifts;
static short *shift_symbol; static short *shift_symbol = NULL;
static short *redset; static short *redset = NULL;
static short *shiftset; static short *shiftset = NULL;
static short **kernel_base; static short **kernel_base = NULL;
static short **kernel_end; static short **kernel_end = NULL;
static short *kernel_items; static short *kernel_items = NULL;
/* hash table for states, to recognize equivalent ones. */ /* hash table for states, to recognize equivalent ones. */
#define STATE_TABLE_SIZE 1009 #define STATE_TABLE_SIZE 1009
static core **state_table; static core **state_table = NULL;
static void static void
allocate_itemsets (void) allocate_itemsets (void)
{ {
short *itemp; short *itemp = NULL;
int symbol; int symbol;
int i; int i;
int count; int count;
short *symbol_count; short *symbol_count = NULL;
count = 0; count = 0;
symbol_count = XCALLOC (short, nsyms); symbol_count = XCALLOC (short, nsyms);
@@ -89,7 +89,8 @@ allocate_itemsets (void)
We allocate that much space for each symbol. */ We allocate that much space for each symbol. */
kernel_base = XCALLOC (short *, nsyms); kernel_base = XCALLOC (short *, nsyms);
kernel_items = XCALLOC (short, count); if (count)
kernel_items = XCALLOC (short, count);
count = 0; count = 0;
for (i = 0; i < nsyms; i++) for (i = 0; i < nsyms; i++)

View File

@@ -143,8 +143,6 @@ size_t strnlen PARAMS ((const char *s, size_t maxlen));
# define LOCALEDIR "/usr/local/share/locale" # define LOCALEDIR "/usr/local/share/locale"
#endif #endif
#endif /* BISON_SYSTEM_H */
/*-----------. /*-----------.
| Booleans. | | Booleans. |
@@ -264,3 +262,17 @@ do { \
# define BISON_HAIRY "c:/usr/local/lib/bison.hairy" # define BISON_HAIRY "c:/usr/local/lib/bison.hairy"
# endif # endif
#endif #endif
/*---------------------------------.
| Debugging the memory allocator. |
`---------------------------------*/
# if WITH_DMALLOC
# define DMALLOC_FUNC_CHECK
# include <dmalloc.h>
# endif /* WITH_DMALLOC */
#endif /* BISON_SYSTEM_H */