Commit 37e365b4 authored by Ted Lemon's avatar Ted Lemon
Browse files

- In reference count history, remember the address where the reference

  is stored as well as the address of the thing referenced.
parent 14bb0a3f
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: alloc.c,v 1.40 2000/01/27 22:14:36 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; "$Id: alloc.c,v 1.41 2000/01/27 22:40:49 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
...@@ -473,7 +473,7 @@ int expression_reference (ptr, src, file, line) ...@@ -473,7 +473,7 @@ int expression_reference (ptr, src, file, line)
} }
*ptr = src; *ptr = src;
src -> refcnt++; src -> refcnt++;
rc_register (file, line, src, src -> refcnt); rc_register (file, line, ptr, src, src -> refcnt);
dmalloc_reuse (src, file, line, 1); dmalloc_reuse (src, file, line, 1);
return 1; return 1;
} }
...@@ -536,7 +536,7 @@ int option_cache_reference (ptr, src, file, line) ...@@ -536,7 +536,7 @@ int option_cache_reference (ptr, src, file, line)
} }
*ptr = src; *ptr = src;
src -> refcnt++; src -> refcnt++;
rc_register (file, line, src, src -> refcnt); rc_register (file, line, ptr, src, src -> refcnt);
dmalloc_reuse (src, file, line, 1); dmalloc_reuse (src, file, line, 1);
return 1; return 1;
} }
...@@ -581,7 +581,7 @@ int buffer_reference (ptr, bp, file, line) ...@@ -581,7 +581,7 @@ int buffer_reference (ptr, bp, file, line)
} }
*ptr = bp; *ptr = bp;
bp -> refcnt++; bp -> refcnt++;
rc_register (file, line, bp, bp -> refcnt); rc_register (file, line, ptr, bp, bp -> refcnt);
dmalloc_reuse (bp, file, line, 1); dmalloc_reuse (bp, file, line, 1);
return 1; return 1;
} }
...@@ -612,7 +612,7 @@ int buffer_dereference (ptr, file, line) ...@@ -612,7 +612,7 @@ int buffer_dereference (ptr, file, line)
} }
(*ptr) -> refcnt--; (*ptr) -> refcnt--;
rc_register (file, line, *ptr, (*ptr) -> refcnt); rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt);
if (!(*ptr) -> refcnt) if (!(*ptr) -> refcnt)
dfree ((*ptr), file, line); dfree ((*ptr), file, line);
if ((*ptr) -> refcnt < 0) { if ((*ptr) -> refcnt < 0) {
...@@ -671,7 +671,7 @@ int dns_host_entry_reference (ptr, bp, file, line) ...@@ -671,7 +671,7 @@ int dns_host_entry_reference (ptr, bp, file, line)
} }
*ptr = bp; *ptr = bp;
bp -> refcnt++; bp -> refcnt++;
rc_register (file, line, bp, bp -> refcnt); rc_register (file, line, ptr, bp, bp -> refcnt);
dmalloc_reuse (bp, file, line, 1); dmalloc_reuse (bp, file, line, 1);
return 1; return 1;
} }
...@@ -693,7 +693,7 @@ int dns_host_entry_dereference (ptr, file, line) ...@@ -693,7 +693,7 @@ int dns_host_entry_dereference (ptr, file, line)
} }
(*ptr) -> refcnt--; (*ptr) -> refcnt--;
rc_register (file, line, bp, bp -> refcnt); rc_register (file, line, ptr, bp, bp -> refcnt);
if (!(*ptr) -> refcnt) if (!(*ptr) -> refcnt)
dfree ((*ptr), file, line); dfree ((*ptr), file, line);
if ((*ptr) -> refcnt < 0) { if ((*ptr) -> refcnt < 0) {
...@@ -741,7 +741,7 @@ int option_state_allocate (ptr, file, line) ...@@ -741,7 +741,7 @@ int option_state_allocate (ptr, file, line)
memset (*ptr, 0, size); memset (*ptr, 0, size);
(*ptr) -> universe_count = universe_count; (*ptr) -> universe_count = universe_count;
(*ptr) -> refcnt = 1; (*ptr) -> refcnt = 1;
rc_register (file, line, *ptr, (*ptr) -> refcnt); rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt);
return 1; return 1;
} }
return 0; return 0;
...@@ -771,7 +771,7 @@ int option_state_reference (ptr, bp, file, line) ...@@ -771,7 +771,7 @@ int option_state_reference (ptr, bp, file, line)
} }
*ptr = bp; *ptr = bp;
bp -> refcnt++; bp -> refcnt++;
rc_register (file, line, bp, bp -> refcnt); rc_register (file, line, ptr, bp, bp -> refcnt);
dmalloc_reuse (bp, file, line, 1); dmalloc_reuse (bp, file, line, 1);
return 1; return 1;
} }
...@@ -796,7 +796,7 @@ int option_state_dereference (ptr, file, line) ...@@ -796,7 +796,7 @@ int option_state_dereference (ptr, file, line)
options = *ptr; options = *ptr;
*ptr = (struct option_state *)0; *ptr = (struct option_state *)0;
--options -> refcnt; --options -> refcnt;
rc_register (file, line, options, options -> refcnt); rc_register (file, line, ptr, options, options -> refcnt);
if (options -> refcnt > 0) if (options -> refcnt > 0)
return 1; return 1;
...@@ -860,7 +860,7 @@ int executable_statement_reference (ptr, bp, file, line) ...@@ -860,7 +860,7 @@ int executable_statement_reference (ptr, bp, file, line)
} }
*ptr = bp; *ptr = bp;
bp -> refcnt++; bp -> refcnt++;
rc_register (file, line, bp, bp -> refcnt); rc_register (file, line, ptr, bp, bp -> refcnt);
dmalloc_reuse (bp, file, line, 1); dmalloc_reuse (bp, file, line, 1);
return 1; return 1;
} }
...@@ -929,7 +929,7 @@ int packet_reference (ptr, bp, file, line) ...@@ -929,7 +929,7 @@ int packet_reference (ptr, bp, file, line)
} }
*ptr = bp; *ptr = bp;
bp -> refcnt++; bp -> refcnt++;
rc_register (file, line, bp, bp -> refcnt); rc_register (file, line, ptr, bp, bp -> refcnt);
dmalloc_reuse (bp, file, line, 1); dmalloc_reuse (bp, file, line, 1);
return 1; return 1;
} }
...@@ -954,7 +954,7 @@ int packet_dereference (ptr, file, line) ...@@ -954,7 +954,7 @@ int packet_dereference (ptr, file, line)
packet = *ptr; packet = *ptr;
*ptr = (struct packet *)0; *ptr = (struct packet *)0;
--packet -> refcnt; --packet -> refcnt;
rc_register (file, line, packet, packet -> refcnt); rc_register (file, line, ptr, packet, packet -> refcnt);
if (packet -> refcnt > 0) if (packet -> refcnt > 0)
return 1; return 1;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: execute.c,v 1.25 2000/01/26 17:20:46 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n"; "$Id: execute.c,v 1.26 2000/01/27 22:40:49 mellon Exp $ Copyright (c) 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
...@@ -446,7 +446,7 @@ int executable_statement_dereference (ptr, file, line) ...@@ -446,7 +446,7 @@ int executable_statement_dereference (ptr, file, line)
} }
(*ptr) -> refcnt--; (*ptr) -> refcnt--;
rc_register (file, line, (*ptr), (*ptr) -> refcnt); rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt);
if ((*ptr) -> refcnt > 0) { if ((*ptr) -> refcnt > 0) {
*ptr = (struct executable_statement *)0; *ptr = (struct executable_statement *)0;
return 1; return 1;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: options.c,v 1.54 2000/01/27 22:16:08 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n"; "$Id: options.c,v 1.55 2000/01/27 22:40:49 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#define DHCP_OPTION_DATA #define DHCP_OPTION_DATA
...@@ -1023,7 +1023,7 @@ int option_cache_dereference (ptr, file, line) ...@@ -1023,7 +1023,7 @@ int option_cache_dereference (ptr, file, line)
} }
(*ptr) -> refcnt--; (*ptr) -> refcnt--;
rc_register (file, line, *ptr, (*ptr) -> refcnt); rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt);
if (!(*ptr) -> refcnt) { if (!(*ptr) -> refcnt) {
if ((*ptr) -> data.buffer) if ((*ptr) -> data.buffer)
data_string_forget (&(*ptr) -> data, file, line); data_string_forget (&(*ptr) -> data, file, line);
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: tree.c,v 1.70 2000/01/26 17:22:58 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n"; "$Id: tree.c,v 1.71 2000/01/27 22:40:49 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
...@@ -1940,7 +1940,7 @@ void expression_dereference (eptr, file, line) ...@@ -1940,7 +1940,7 @@ void expression_dereference (eptr, file, line)
/* Decrement the reference count. If it's nonzero, we're /* Decrement the reference count. If it's nonzero, we're
done. */ done. */
--(expr -> refcnt); --(expr -> refcnt);
rc_register (file, line, expr, expr -> refcnt); rc_register (file, line, eptr, expr, expr -> refcnt);
if (expr -> refcnt > 0) if (expr -> refcnt > 0)
return; return;
if (expr -> refcnt < 0) { if (expr -> refcnt < 0) {
......
...@@ -46,7 +46,7 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h, ...@@ -46,7 +46,7 @@ dhcpctl_status dhcpctl_new_object (dhcpctl_handle *h,
memset (m, 0, sizeof *m); memset (m, 0, sizeof *m);
m -> type = dhcpctl_remote_type; m -> type = dhcpctl_remote_type;
m -> refcnt = 1; m -> refcnt = 1;
rc_register_mdl (m, m -> refcnt); rc_register_mdl (&m, m, m -> refcnt);
g = (omapi_object_t *)0; g = (omapi_object_t *)0;
status = omapi_generic_new (&g, MDL); status = omapi_generic_new (&g, MDL);
......
...@@ -38,7 +38,7 @@ isc_result_t omapi_connect (omapi_object_t *c, ...@@ -38,7 +38,7 @@ isc_result_t omapi_connect (omapi_object_t *c,
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj); memset (obj, 0, sizeof *obj);
obj -> refcnt = 1; obj -> refcnt = 1;
rc_register_mdl (obj, obj -> refcnt); rc_register_mdl (&obj, obj, obj -> refcnt);
obj -> type = omapi_type_connection; obj -> type = omapi_type_connection;
status = omapi_object_reference (&c -> outer, (omapi_object_t *)obj, status = omapi_object_reference (&c -> outer, (omapi_object_t *)obj,
......
...@@ -55,7 +55,7 @@ isc_result_t omapi_register_io_object (omapi_object_t *h, ...@@ -55,7 +55,7 @@ isc_result_t omapi_register_io_object (omapi_object_t *h,
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj); memset (obj, 0, sizeof *obj);
obj -> refcnt = 1; obj -> refcnt = 1;
rc_register_mdl (obj, obj -> refcnt); rc_register_mdl (&obj, obj, obj -> refcnt);
obj -> type = omapi_type_io_object; obj -> type = omapi_type_io_object;
status = omapi_object_reference (&obj -> inner, h, MDL); status = omapi_object_reference (&obj -> inner, h, MDL);
...@@ -107,7 +107,7 @@ isc_result_t omapi_wait_for_completion (omapi_object_t *object, ...@@ -107,7 +107,7 @@ isc_result_t omapi_wait_for_completion (omapi_object_t *object,
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (waiter, 0, sizeof *waiter); memset (waiter, 0, sizeof *waiter);
waiter -> refcnt = 1; waiter -> refcnt = 1;
rc_register_mdl (waiter, waiter -> refcnt); rc_register_mdl (&waiter, waiter, waiter -> refcnt);
waiter -> type = omapi_type_waiter; waiter -> type = omapi_type_waiter;
/* Paste the waiter object onto the inner object we're /* Paste the waiter object onto the inner object we're
......
...@@ -37,7 +37,7 @@ isc_result_t omapi_listen (omapi_object_t *h, ...@@ -37,7 +37,7 @@ isc_result_t omapi_listen (omapi_object_t *h,
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj); memset (obj, 0, sizeof *obj);
obj -> refcnt = 1; obj -> refcnt = 1;
rc_register_mdl (obj, obj -> refcnt); rc_register_mdl (&obj, obj, obj -> refcnt);
obj -> type = omapi_type_listener; obj -> type = omapi_type_listener;
/* Connect this object to the inner object. */ /* Connect this object to the inner object. */
...@@ -139,7 +139,7 @@ isc_result_t omapi_accept (omapi_object_t *h) ...@@ -139,7 +139,7 @@ isc_result_t omapi_accept (omapi_object_t *h)
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj); memset (obj, 0, sizeof *obj);
obj -> refcnt = 1; obj -> refcnt = 1;
rc_register_mdl (obj, obj -> refcnt); rc_register_mdl (&obj, obj, obj -> refcnt);
obj -> type = omapi_type_connection; obj -> type = omapi_type_connection;
/* Accept the connection. */ /* Accept the connection. */
......
...@@ -35,7 +35,7 @@ isc_result_t omapi_message_new (omapi_object_t **o, const char *file, int line) ...@@ -35,7 +35,7 @@ isc_result_t omapi_message_new (omapi_object_t **o, const char *file, int line)
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (m, 0, sizeof *m); memset (m, 0, sizeof *m);
m -> type = omapi_type_message; m -> type = omapi_type_message;
rc_register (file, line, m, m -> refcnt); rc_register (file, line, &m, m, m -> refcnt);
m -> refcnt = 1; m -> refcnt = 1;
g = (omapi_object_t *)0; g = (omapi_object_t *)0;
......
...@@ -35,7 +35,7 @@ isc_result_t omapi_protocol_connect (omapi_object_t *h, ...@@ -35,7 +35,7 @@ isc_result_t omapi_protocol_connect (omapi_object_t *h,
return ISC_R_NOMEMORY; return ISC_R_NOMEMORY;
memset (obj, 0, sizeof *obj); memset (obj, 0, sizeof *obj);
obj -> refcnt = 1; obj -> refcnt = 1;
rc_register_mdl (obj, obj -> refcnt); rc_register_mdl (&obj, obj, obj -> refcnt);
obj -> type = omapi_type_protocol; obj -> type = omapi_type_protocol;
status = omapi_connect ((omapi_object_t *)obj, server_name, port); status = omapi_connect ((omapi_object_t *)obj, server_name, port);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment