summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/isakmpd/Makefile28
-rw-r--r--sbin/isakmpd/sysdep.h25
-rw-r--r--sbin/isakmpd/util.c13
3 files changed, 39 insertions, 27 deletions
diff --git a/sbin/isakmpd/Makefile b/sbin/isakmpd/Makefile
index b57f1d312c1..f3e7d1136c7 100644
--- a/sbin/isakmpd/Makefile
+++ b/sbin/isakmpd/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.54 2004/06/21 23:28:18 ho Exp $
+# $OpenBSD: Makefile,v 1.55 2004/06/23 01:17:29 ho Exp $
# $EOM: Makefile,v 1.78 2000/10/15 21:33:42 niklas Exp $
#
@@ -96,31 +96,9 @@ CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes \
# If you like to use Boehm's garbage collector (/usr/ports/devel/boehm-gc).
#LDADD+= -L/usr/local/lib -lgc
#DPADD+= /usr/local/lib/libgc.a
-
+#CFLAGS+= -DUSE_BOEHM_GC
# You can also use Boehm's garbage collector as a means to find leaks.
-# XXX The defines below are GCC-specific. I think it is OK to require
-# XXX GCC if you are debugging isakmpd in this way.
-#LDADD+= -L/usr/local/lib -lleak
-#DPADD+= /usr/local/lib/libleak.a
-#CFLAGS+= -D'malloc(x)=({ \
-# void *GC_debug_malloc (size_t, char *, int); \
-# GC_debug_malloc ((x), __FILE__, __LINE__); \
-# })' \
-# -D'realloc(x,y)=({ \
-# void *GC_debug_realloc (void *, size_t, char *, int); \
-# GC_debug_realloc ((x), (y), __FILE__, __LINE__); \
-# })' \
-# -D'free(x)=({ \
-# void GC_debug_free (void *); \
-# GC_debug_free (x); \
-# })' \
-# -D'calloc(x,y)=malloc((x) * (y))' \
-# -D'strdup(x)=({ \
-# char *strcpy (char *, const char *); \
-# const char *_x_ = (x); \
-# char *_y_ = malloc (strlen (_x_) + 1); \
-# strcpy (_y_, _x_); \
-# })'
+# # setenv GC_FIND_LEAK
SUBDIR= apps
diff --git a/sbin/isakmpd/sysdep.h b/sbin/isakmpd/sysdep.h
index 45e116f88ed..a8745f41884 100644
--- a/sbin/isakmpd/sysdep.h
+++ b/sbin/isakmpd/sysdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysdep.h,v 1.15 2004/04/15 18:39:26 deraadt Exp $ */
+/* $OpenBSD: sysdep.h,v 1.16 2004/06/23 01:17:29 ho Exp $ */
/* $EOM: sysdep.h,v 1.17 2000/12/04 04:46:35 angelos Exp $ */
/*
@@ -33,6 +33,10 @@
#define _SYSDEP_H_
#include <sys/types.h>
+#if defined (USE_BOEHM_GC)
+#include <stdlib.h>
+#include <string.h>
+#endif
#include "sysdep-os.h"
@@ -59,4 +63,23 @@ extern char *sysdep_progname(void);
extern u_int32_t sysdep_random(void);
extern u_int8_t sysdep_sa_len(struct sockaddr *);
+#if defined (USE_BOEHM_GC)
+/*
+ * Use Boehm's garbage collector as a means to find leaks.
+ * XXX The defines below are GCC-specific. I think it is OK to require
+ * XXX GCC if you are debugging isakmpd in this way.
+ */
+void *GC_debug_malloc(size_t, char *, int);
+void *GC_debug_realloc(void *, size_t, char *, int);
+void GC_debug_free(void *);
+char *my_strdup(const char *);
+
+#define malloc(x) GC_debug_malloc ((x), __FILE__, __LINE__)
+#define realloc(x,y) GC_debug_realloc ((x), (y), __FILE__, __LINE__)
+#define free(x) GC_debug_free (x)
+#define calloc(x,y) malloc((x) * (y))
+#define strdup(x) my_strdup((x))
+
+#endif /* WITH_BOEHM_GC */
+
#endif /* _SYSDEP_H_ */
diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c
index f94c503f9ee..5778a227b81 100644
--- a/sbin/isakmpd/util.c
+++ b/sbin/isakmpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.43 2004/06/20 15:24:05 ho Exp $ */
+/* $OpenBSD: util.c,v 1.44 2004/06/23 01:17:29 ho Exp $ */
/* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */
/*
@@ -558,3 +558,14 @@ check_file_secrecy_fd(int fd, char *name, size_t *file_size)
return 0;
}
+
+/* Special for compiling with Boehms GC. See Makefile and sysdep.h */
+#if defined (USE_BOEHM_GC)
+char *
+my_strdup(const char *x)
+{
+ char *strcpy(char *,const char *);
+ char *y = malloc(strlen(x) + 1);
+ return strcpy(y,x);
+}
+#endif