]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Add a scary debugging mode for finding host allocation errors.
authorTed Lemon <source@isc.org>
Fri, 27 Apr 2001 21:30:15 +0000 (21:30 +0000)
committerTed Lemon <source@isc.org>
Fri, 27 Apr 2001 21:30:15 +0000 (21:30 +0000)
server/salloc.c

index ece8733d3c77efac5455d99ac1395ce7014db8c3..d374d3cb59821b51798eee2d11388a0af5cff004 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: salloc.c,v 1.1 2000/05/16 23:11:42 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: salloc.c,v 1.2 2001/04/27 21:30:15 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -61,7 +61,36 @@ struct lease *new_leases (n, file, line)
 OMAPI_OBJECT_ALLOC (lease, struct lease, dhcp_type_lease)
 OMAPI_OBJECT_ALLOC (class, struct class, dhcp_type_class)
 OMAPI_OBJECT_ALLOC (pool, struct pool, dhcp_type_pool)
+
+#if !defined (NO_HOST_FREES)   /* Scary debugging mode - don't enable! */
 OMAPI_OBJECT_ALLOC (host, struct host_decl, dhcp_type_host)
+#else
+isc_result_t host_allocate (struct host_decl **p, const char *file, int line)
+{
+       return omapi_object_allocate ((omapi_object_t **)p,
+                                     dhcp_type_host, 0, file, line);
+}
+
+isc_result_t host_reference (struct host_decl **pptr, struct host_decl *ptr,
+                              const char *file, int line)
+{
+       return omapi_object_reference ((omapi_object_t **)pptr,
+                                      (omapi_object_t *)ptr, file, line);
+}
+
+isc_result_t host_dereference (struct host_decl **ptr,
+                              const char *file, int line)
+{
+       if ((*ptr) -> refcnt == 1) {
+               log_error ("host dereferenced with refcnt == 1.");
+#if defined (DEBUG_RC_HISTORY)
+               dump_rc_history ();
+#endif
+               abort ();
+       }
+       return omapi_object_dereference ((omapi_object_t **)ptr, file, line);
+}
+#endif
 
 struct lease_state *free_lease_states;