if test "$enable_debug" = yes ; then
AC_DEFINE(PATH_CONFIG_DIR, ".")
AC_DEFINE(DEBUGGING)
- AC_CHECK_LIB(efence, malloc)
+ AC_CHECK_LIB(dmalloc, dmalloc_debug)
+ if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
+ AC_CHECK_LIB(efence, malloc)
+ fi
else
AC_DEFINE_UNQUOTED(PATH_CONFIG_DIR, "$sysconfdir")
fi
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "nest/bird.h"
#include "lib/resource.h"
return b->data;
}
+void *
+mb_allocz(pool *p, unsigned size)
+{
+ void *x = mb_alloc(p, size);
+ bzero(x, size);
+ return x;
+}
+
void
mb_free(void *m)
{
/* Normal memory blocks */
void *mb_alloc(pool *, unsigned size);
+void *mb_allocz(pool *, unsigned size);
void mb_free(void *);
/* Memory pools with linear allocation */
void *sl_alloc(slab *);
void sl_free(slab *, void *);
-/* Low-level memory allocation functions, please don't use */
+/*
+ * Low-level memory allocation functions, please don't use
+ * outside resource manager and possibly sysdep code.
+ */
+#ifdef HAVE_LIBDMALLOC
+/*
+ * The standard dmalloc macros tend to produce lots of namespace
+ * conflicts and we use only xmalloc and xfree, so we can define
+ * the stubs ourselves.
+ */
+#define DMALLOC_DISABLE
+#include <dmalloc.h>
+#define xmalloc(size) _xmalloc_leap(__FILE__, __LINE__, size)
+#define xfree(ptr) _xfree_leap(__FILE__, __LINE__, ptr)
+#else
void *xmalloc(unsigned);
#define xfree(x) free(x)
+#endif
#endif
/*
* BIRD Library -- malloc() With Checking
*
- * (c) 1998 Martin Mares <mj@ucw.cz>
+ * (c) 1998--1999 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include "nest/bird.h"
#include "lib/resource.h"
+#ifndef HAVE_LIBDMALLOC
+
void *
xmalloc(unsigned size)
{
return p;
die("Unable to allocate %d bytes of memory", size);
}
+
+#endif
/* Path to configuration files */
#define PATH_CONFIG_DIR ?
+
+/* Are we using dmalloc? */
+#undef HAVE_LIBDMALLOC
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/signal.h>
int
main(int argc, char **argv)
{
+#ifdef HAVE_LIBDMALLOC
+ if (!getenv("DMALLOC_OPTIONS"))
+ dmalloc_debug(0x2f03d00);
+#endif
+
log_init_debug(NULL);
parse_args(argc, argv);
set -e ; for a in $(static-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done
$(exedir)/bird: $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a
- $(CC) $(LDFLAGS) -o $@ $^
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
.dir-stamp:
mkdir -p $(static-dirs)
CPPFLAGS=-I$(root-rel) -I$(srcdir)
CFLAGS=$(CPPFLAGS) @CFLAGS@
-LDFLAGS=@LIBS@
+LDFLAGS=
+LIBS=@LIBS@
CC=@CC@
M4=@M4@
BISON=@BISON@