44 log_error (
"%s(%d): null pointer", file, line);
45 #if defined (POINTER_DEBUG)
52 log_error (
"%s(%d): non-null pointer", file, line);
53 #if defined (POINTER_DEBUG)
60 h =
dmalloc (
sizeof *h, file, line);
62 memset (h, 0,
sizeof *h);
75 log_error (
"%s(%d): null pointer", file, line);
76 #if defined (POINTER_DEBUG)
83 log_error (
"%s(%d): non-null pointer", file, line);
84 #if defined (POINTER_DEBUG)
105 log_error (
"%s(%d): null pointer", file, line);
106 #if defined (POINTER_DEBUG)
113 option_chain_head = *ptr;
114 *ptr = (
struct option_chain_head *)0;
115 --option_chain_head ->
refcnt;
118 if (option_chain_head ->
refcnt > 0)
121 if (option_chain_head ->
refcnt < 0) {
122 log_error (
"%s(%d): negative refcnt!", file, line);
123 #if defined (DEBUG_RC_HISTORY)
124 dump_rc_history (option_chain_head);
126 #if defined (POINTER_DEBUG)
134 for (car = option_chain_head ->
first; car; car = cdr) {
142 dfree (option_chain_head, file, line);
154 log_error (
"%s(%d): null pointer", file, line);
155 #if defined (POINTER_DEBUG)
162 log_error (
"%s(%d): non-null pointer", file, line);
163 #if defined (POINTER_DEBUG)
166 *ptr = (
struct group *)0;
170 g =
dmalloc (
sizeof *g, file, line);
172 memset (g, 0,
sizeof *g);
185 log_error (
"%s(%d): null pointer", file, line);
186 #if defined (POINTER_DEBUG)
193 log_error (
"%s(%d): non-null pointer", file, line);
194 #if defined (POINTER_DEBUG)
197 *ptr = (
struct group *)0;
214 log_error (
"%s(%d): null pointer", file, line);
215 #if defined (POINTER_DEBUG)
223 *ptr = (
struct group *)0;
229 if (group ->
refcnt < 0) {
230 log_error (
"%s(%d): negative refcnt!", file, line);
231 #if defined (DEBUG_RC_HISTORY)
232 dump_rc_history (group);
234 #if defined (POINTER_DEBUG)
242 group_object_dereference (&group ->
object, file, line);
244 subnet_dereference (&group ->
subnet, file, line);
253 dfree (group, file, line);
298 dfree ((
void *)ptr, file, line);
314 memcpy(rval + 1, name, len);
315 rval->
name = (
char *)(rval + 1);
335 dfree ((
void *)ptr, file, line);
343 dfree ((
void *)ptr, file, line);
351 dfree ((
void *)ptr, file, line);
359 dfree ((
void *)ptr, file, line);
375 dfree (lease, file, line);
388 free_pairs = foo -> cdr;
389 memset (foo, 0,
sizeof *foo);
394 foo =
dmalloc (
sizeof *foo, file, line);
397 memset (foo, 0,
sizeof *foo);
411 #if defined (DEBUG_MEMORY_LEAKAGE) || \
412 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
413 void relinquish_free_pairs ()
417 for (pf = free_pairs; pf; pf = pc) {
421 free_pairs = (
pair)0;
434 if (free_expressions) {
436 free_expressions = rval ->
data.
not;
443 memset (rval, 0,
sizeof *rval);
454 log_error (
"%s(%d): null pointer", file, line);
455 #if defined (POINTER_DEBUG)
462 log_error (
"%s(%d): non-null pointer", file, line);
463 #if defined (POINTER_DEBUG)
481 free_expressions = expr;
485 #if defined (DEBUG_MEMORY_LEAKAGE) || \
486 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
487 void relinquish_free_expressions ()
491 for (e = free_expressions; e; e = n) {
508 if (free_binding_values) {
510 free_binding_values = rval ->
value.
bv;
517 memset (rval, 0,
sizeof *rval);
528 log_error (
"%s(%d): null pointer", file, line);
529 #if defined (POINTER_DEBUG)
536 log_error (
"%s(%d): non-null pointer", file, line);
537 #if defined (POINTER_DEBUG)
555 free_binding_values = bv;
559 #if defined (DEBUG_MEMORY_LEAKAGE) || \
560 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
561 void relinquish_free_binding_values ()
565 for (b = free_binding_values; b; b = n) {
583 memset (rval, 0,
sizeof *rval);
594 log_error (
"%s(%d): null pointer", file, line);
595 #if defined (POINTER_DEBUG)
602 log_error (
"%s(%d): non-null pointer", file, line);
603 #if defined (POINTER_DEBUG)
606 *ptr = (
struct fundef *)0;
617 #if defined (DEBUG_MEMORY_LEAKAGE) || \
618 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
619 void relinquish_free_option_caches ()
623 for (o = free_option_caches; o; o = n) {
638 if (free_option_caches) {
648 memset (rval, 0,
sizeof *rval);
659 log_error (
"%s(%d): null pointer", file, line);
660 #if defined (POINTER_DEBUG)
667 log_error (
"%s(%d): non-null pointer", file, line);
668 #if defined (POINTER_DEBUG)
690 bp =
dmalloc (len +
sizeof *bp, file, line);
694 memset (bp, 0,
sizeof *bp);
706 log_error (
"%s(%d): null pointer", file, line);
707 #if defined (POINTER_DEBUG)
714 log_error (
"%s(%d): non-null pointer", file, line);
715 #if defined (POINTER_DEBUG)
718 *ptr = (
struct buffer *)0;
733 log_error (
"%s(%d): null pointer", file, line);
734 #if defined (POINTER_DEBUG)
742 log_error (
"%s(%d): null pointer", file, line);
743 #if defined (POINTER_DEBUG)
753 dfree ((*ptr), file, line);
754 }
else if ((*ptr) ->
refcnt < 0) {
755 log_error (
"%s(%d): negative refcnt!", file, line);
756 #if defined (DEBUG_RC_HISTORY)
757 dump_rc_history (*ptr);
759 #if defined (POINTER_DEBUG)
765 *ptr = (
struct buffer *)0;
771 const
char *hostname;
777 bp =
dmalloc (strlen (hostname) +
sizeof *bp, file, line);
780 memset (bp, 0,
sizeof *bp);
782 strcpy (bp -> hostname, hostname);
793 log_error (
"%s(%d): null pointer", file, line);
794 #if defined (POINTER_DEBUG)
801 log_error (
"%s(%d): non-null pointer", file, line);
802 #if defined (POINTER_DEBUG)
820 log_error (
"%s(%d): null pointer", file, line);
821 #if defined (POINTER_DEBUG)
830 if ((*ptr)->refcnt == 0) {
831 dfree ((*ptr), file, line);
832 }
else if ((*ptr)->refcnt < 0) {
833 log_error (
"%s(%d): negative refcnt!", file, line);
834 #if defined (DEBUG_RC_HISTORY)
835 dump_rc_history (*ptr);
837 #if defined (POINTER_DEBUG)
855 log_error (
"%s(%d): null pointer", file, line);
856 #if defined (POINTER_DEBUG)
863 log_error (
"%s(%d): non-null pointer", file, line);
864 #if defined (POINTER_DEBUG)
872 *ptr =
dmalloc (size, file, line);
874 memset (*ptr, 0, size);
891 log_error (
"%s(%d): null pointer", file, line);
892 #if defined (POINTER_DEBUG)
899 log_error (
"%s(%d): non-null pointer", file, line);
900 #if defined (POINTER_DEBUG)
921 log_error (
"%s(%d): null pointer", file, line);
922 #if defined (POINTER_DEBUG)
933 if (options ->
refcnt > 0)
936 if (options ->
refcnt < 0) {
937 log_error (
"%s(%d): negative refcnt!", file, line);
938 #if defined (DEBUG_RC_HISTORY)
939 dump_rc_history (options);
941 #if defined (POINTER_DEBUG)
955 dfree (options, file, line);
966 bp =
dmalloc (
sizeof *bp, file, line);
969 memset (bp, 0,
sizeof *bp);
980 log_error (
"%s(%d): null pointer", file, line);
981 #if defined (POINTER_DEBUG)
988 log_error (
"%s(%d): non-null pointer", file, line);
989 #if defined (POINTER_DEBUG)
1001 static struct packet *free_packets;
1003 #if defined (DEBUG_MEMORY_LEAKAGE) || \
1004 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1005 void relinquish_free_packets ()
1008 for (p = free_packets; p; p = n) {
1012 free_packets = (
struct packet *)0;
1024 log_error (
"%s(%d): null pointer", file, line);
1025 #if defined (POINTER_DEBUG)
1032 log_error (
"%s(%d): non-null pointer", file, line);
1033 #if defined (POINTER_DEBUG)
1036 *ptr = (
struct packet *)0;
1042 free_packets = (
struct packet *)(p ->
raw);
1045 p =
dmalloc (
sizeof *p, file, line);
1048 memset (p, 0,
sizeof *p);
1061 log_error (
"%s(%d): null pointer", file, line);
1062 #if defined (POINTER_DEBUG)
1069 log_error (
"%s(%d): non-null pointer", file, line);
1070 #if defined (POINTER_DEBUG)
1073 *ptr = (
struct packet *)0;
1090 if (!ptr || !*ptr) {
1091 log_error (
"%s(%d): null pointer", file, line);
1092 #if defined (POINTER_DEBUG)
1100 *ptr = (
struct packet *)0;
1103 if (packet ->
refcnt > 0)
1106 if (packet ->
refcnt < 0) {
1107 log_error (
"%s(%d): negative refcnt!", file, line);
1108 #if defined (DEBUG_RC_HISTORY)
1109 dump_rc_history (packet);
1111 #if defined (POINTER_DEBUG)
1130 free_packets = packet;
1143 log_error (
"%s(%d): null pointer", file, line);
1144 #if defined (POINTER_DEBUG)
1151 log_error (
"%s(%d): non-null pointer", file, line);
1152 #if defined (POINTER_DEBUG)
1159 d =
dmalloc (
sizeof *d, file, line);
1161 memset (d, 0,
sizeof *d);
1174 log_error (
"%s(%d): null pointer", file, line);
1175 #if defined (POINTER_DEBUG)
1182 log_error (
"%s(%d): non-null pointer", file, line);
1183 #if defined (POINTER_DEBUG)
1203 log_error (
"%s(%d): null pointer", file, line);
1204 #if defined (POINTER_DEBUG)
1212 log_error (
"%s(%d): non-null pointer", file, line);
1213 #if defined (POINTER_DEBUG)
1220 bp =
dmalloc (
sizeof *bp, file, line);
1223 memset (bp, 0,
sizeof *bp);
1235 log_error (
"%s(%d): null pointer", file, line);
1236 #if defined (POINTER_DEBUG)
1243 log_error (
"%s(%d): non-null pointer", file, line);
1244 #if defined (POINTER_DEBUG)
1274 const char *src,
unsigned int len,
1277 unsigned int copy_len = 0;
1279 if (new_string == NULL) {
1280 log_error(
"data_string_new: new_string cannot be NULL %s(%d)",
1286 log_error(
"data_string_new: src cannot be NULL %s(%d)",
1291 memset(new_string, 0,
sizeof (
struct data_string));
1295 copy_len = (len > 0 && src[len - 1 ] == 0) ? len - 1 : len;
1299 log_error(
"data_string_new: No memory %s(%d)", file, line);
1305 memcpy(new_string->
buffer->
data, src, copy_len);
1314 new_string->
len = copy_len;
1332 dest -> data = src -> data;
1333 dest -> terminated = src -> terminated;
1334 dest -> len = src -> len;
1347 memset (data, 0,
sizeof *data);
1358 if (len < dp -> len) {
1359 dp -> terminated = 0;
#define rc_register(file, line, reference, addr, refcnt, d, f)
int data_string_new(struct data_string *new_string, const char *src, unsigned int len, const char *file, int line)
Constructs a null-terminated data_string from a char* and length.
int executable_statement_reference(struct executable_statement **ptr, struct executable_statement *bp, const char *file, int line)
int executable_statement_allocate(struct executable_statement **ptr, const char *file, int line)
int fundef_reference(struct fundef **ptr, struct fundef *src, const char *file, int line)
struct option_cache * free_option_caches
int executable_statement_dereference(struct executable_statement **ptr, const char *file, int line)
struct universe * new_universe(char *file, int line) const
isc_result_t omapi_object_dereference(omapi_object_t **h, const char *file, int line)
int option_cache_dereference(struct option_cache **ptr, const char *file, int line)
void free_domain_search_list(struct domain_search_list *ptr, const char *file, int line)
int expression_allocate(struct expression **cptr, const char *file, int line)
int binding_value_reference(struct binding_value **ptr, struct binding_value *src, const char *file, int line)
pair new_pair(char *file, int line) const
int group_reference(struct group **ptr, struct group *bp, const char *file, int line)
void data_string_forget(struct data_string *data, const char *file, int line)
void free_universe(struct universe *ptr, const char *file, int line)
int option_cache_reference(struct option_cache **ptr, struct option_cache *src, const char *file, int line)
int fundef_allocate(struct fundef **cptr, const char *file, int line)
int log_error(const char *,...) __attribute__((__format__(__printf__
int dns_zone_reference(struct dns_zone **ptr, struct dns_zone *bp, const char *file, int line)
struct domain_search_list * new_domain_search_list(char *file, int line) const
struct name_server * new_name_server(char *file, int line) const
struct option_state * options
void data_string_truncate(struct data_string *dp, int len)
void free_name_server(struct name_server *ptr, const char *file, int line)
int buffer_reference(struct buffer **ptr, struct buffer *bp, const char *file, int line)
int binding_value_allocate(struct binding_value **cptr, const char *file, int line)
struct executable_statement * statements
int option_cache_allocate(struct option_cache **cptr, const char *file, int line)
int option_state_reference(struct option_state **ptr, struct option_state *bp, const char *file, int line)
union expression::expr_union data
int option_state_allocate(struct option_state **ptr, const char *file, int line)
int option_chain_head_dereference(struct option_chain_head **ptr, const char *file, int line)
int packet_reference(struct packet **ptr, struct packet *bp, const char *file, int line)
int buffer_allocate(struct buffer **ptr, unsigned len, const char *file, int line)
struct class * classes[PACKET_MAX_CLASSES]
struct interface_info * interface
int binding_scope_allocate(struct binding_scope **ptr, const char *file, int line)
int group_dereference(struct group **ptr, const char *file, int line)
int group_allocate(struct group **ptr, const char *file, int line)
void dfree(void *ptr, const char *file, int line)
struct binding_value * free_binding_values
struct expression * free_expressions
struct option * new_option(char *name, const char *file, int line) const
int option_chain_head_reference(struct option_chain_head **ptr, struct option_chain_head *bp, const char *file, int line)
struct dhcp_packet * dhcp_free_list
void free_client_lease(struct client_lease *lease, const char *file, int line)
struct packet * packet_free_list
union binding_value::value value
struct universe ** universes
int option_state_dereference(struct option_state **ptr, const char *file, int line)
int binding_scope_reference(struct binding_scope **ptr, struct binding_scope *bp, const char *file, int line)
void free_protocol(struct protocol *ptr, const char *file, int line)
void free_pair(pair foo, const char *file, int line)
int packet_dereference(struct packet **ptr, const char *file, int line)
int packet_allocate(struct packet **ptr, const char *file, int line)
void * dmalloc(unsigned size, const char *file, int line)
int option_chain_head_allocate(struct option_chain_head **ptr, const char *file, int line)
void free_expression(struct expression *expr, const char *file, int line)
struct client_lease * new_client_lease(char *file, int line) const
#define dmalloc_reuse(x, y, l, z)
struct protocol * new_protocol(char *file, int line) const
int expression_reference(struct expression **ptr, struct expression *src, const char *file, int line)
int dns_host_entry_allocate(struct dns_host_entry **ptr, const char *hostname, const char *file, int line)
int dns_host_entry_dereference(struct dns_host_entry **ptr, const char *file, int line)
struct binding_value * bv
int dns_zone_allocate(struct dns_zone **ptr, const char *file, int line)
const unsigned char * data
void data_string_copy(struct data_string *dest, const struct data_string *src, const char *file, int line)
void free_binding_value(struct binding_value *bv, const char *file, int line)
int dns_host_entry_reference(struct dns_host_entry **ptr, struct dns_host_entry *bp, const char *file, int line)
struct dhcp_packet * new_dhcp_packet(char *file, int line) const
#define PACKET_MAX_CLASSES
void free_dhcp_packet(struct dhcp_packet *ptr, const char *file, int line)
int buffer_dereference(struct buffer **ptr, const char *file, int line)