Revision 7a2105be

View differences:

configure.in
109 109
if test "$enable_debug" = yes ; then
110 110
	AC_DEFINE(PATH_CONFIG_DIR, ".")
111 111
	AC_DEFINE(DEBUGGING)
112
	AC_CHECK_LIB(efence, malloc)
112
	AC_CHECK_LIB(dmalloc, dmalloc_debug)
113
	if test $ac_cv_lib_dmalloc_dmalloc_debug != yes ; then
114
		AC_CHECK_LIB(efence, malloc)
115
	fi
113 116
else
114 117
	AC_DEFINE_UNQUOTED(PATH_CONFIG_DIR, "$sysconfdir")
115 118
fi
lib/resource.c
8 8

  
9 9
#include <stdio.h>
10 10
#include <stdlib.h>
11
#include <string.h>
11 12

  
12 13
#include "nest/bird.h"
13 14
#include "lib/resource.h"
......
156 157
  return b->data;
157 158
}
158 159

  
160
void *
161
mb_allocz(pool *p, unsigned size)
162
{
163
  void *x = mb_alloc(p, size);
164
  bzero(x, size);
165
  return x;
166
}
167

  
159 168
void
160 169
mb_free(void *m)
161 170
{
lib/resource.h
43 43
/* Normal memory blocks */
44 44

  
45 45
void *mb_alloc(pool *, unsigned size);
46
void *mb_allocz(pool *, unsigned size);
46 47
void mb_free(void *);
47 48

  
48 49
/* Memory pools with linear allocation */
......
62 63
void *sl_alloc(slab *);
63 64
void sl_free(slab *, void *);
64 65

  
65
/* Low-level memory allocation functions, please don't use */
66
/*
67
 * Low-level memory allocation functions, please don't use
68
 * outside resource manager and possibly sysdep code.
69
 */
66 70

  
71
#ifdef HAVE_LIBDMALLOC
72
/*
73
 * The standard dmalloc macros tend to produce lots of namespace
74
 * conflicts and we use only xmalloc and xfree, so we can define
75
 * the stubs ourselves.
76
 */
77
#define DMALLOC_DISABLE
78
#include <dmalloc.h>
79
#define xmalloc(size) _xmalloc_leap(__FILE__, __LINE__, size)
80
#define xfree(ptr) _xfree_leap(__FILE__, __LINE__, ptr)
81
#else
67 82
void *xmalloc(unsigned);
68 83
#define xfree(x) free(x)
84
#endif
69 85

  
70 86
#endif
lib/xmalloc.c
1 1
/*
2 2
 *	BIRD Library -- malloc() With Checking
3 3
 *
4
 *	(c) 1998 Martin Mares <mj@ucw.cz>
4
 *	(c) 1998--1999 Martin Mares <mj@ucw.cz>
5 5
 *
6 6
 *	Can be freely distributed and used under the terms of the GNU GPL.
7 7
 */
......
11 11
#include "nest/bird.h"
12 12
#include "lib/resource.h"
13 13

  
14
#ifndef HAVE_LIBDMALLOC
15

  
14 16
void *
15 17
xmalloc(unsigned size)
16 18
{
......
19 21
    return p;
20 22
  die("Unable to allocate %d bytes of memory", size);
21 23
}
24

  
25
#endif
sysdep/autoconf.h.in
40 40

  
41 41
/* Path to configuration files */
42 42
#define PATH_CONFIG_DIR ?
43

  
44
/* Are we using dmalloc? */
45
#undef HAVE_LIBDMALLOC
sysdep/unix/main.c
8 8

  
9 9
#include <stdio.h>
10 10
#include <string.h>
11
#include <stdlib.h>
11 12
#include <fcntl.h>
12 13
#include <unistd.h>
13 14
#include <sys/signal.h>
......
186 187
int
187 188
main(int argc, char **argv)
188 189
{
190
#ifdef HAVE_LIBDMALLOC
191
  if (!getenv("DMALLOC_OPTIONS"))
192
    dmalloc_debug(0x2f03d00);
193
#endif
194

  
189 195
  log_init_debug(NULL);
190 196
  parse_args(argc, argv);
191 197

  
tools/Makefile.in
14 14
	set -e ; for a in $(static-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done
15 15

  
16 16
$(exedir)/bird: $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a
17
	$(CC) $(LDFLAGS) -o $@ $^
17
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
18 18

  
19 19
.dir-stamp:
20 20
	mkdir -p $(static-dirs)
tools/Rules.in
18 18

  
19 19
CPPFLAGS=-I$(root-rel) -I$(srcdir)
20 20
CFLAGS=$(CPPFLAGS) @CFLAGS@
21
LDFLAGS=@LIBS@
21
LDFLAGS=
22
LIBS=@LIBS@
22 23
CC=@CC@
23 24
M4=@M4@
24 25
BISON=@BISON@

Also available in: Unified diff