3 Memory allocation... */
6 * Copyright (c) 1996-2002 Internet Software Consortium.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
38 * To learn more about the Internet Software Consortium, see
39 * ``http://www.isc.org/''. To learn more about Vixie Enterprises,
40 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
41 * ``http://www.nominum.com''.
45 static char copyright[] =
46 "$Id: alloc.c,v 1.53.2.9 2002/11/17 02:26:56 dhankins Exp $ Copyright (c) 1996-2002 The Internet Software Consortium. All rights reserved.\n";
50 #include <omapip/omapip_p.h>
52 struct dhcp_packet *dhcp_free_list;
53 struct packet *packet_free_list;
55 int option_chain_head_allocate (ptr, file, line)
56 struct option_chain_head **ptr;
61 struct option_chain_head *h;
64 log_error ("%s(%d): null pointer", file, line);
65 #if defined (POINTER_DEBUG)
72 log_error ("%s(%d): non-null pointer", file, line);
73 #if defined (POINTER_DEBUG)
76 *ptr = (struct option_chain_head *)0;
80 h = dmalloc (sizeof *h, file, line);
82 memset (h, 0, sizeof *h);
83 return option_chain_head_reference (ptr, h, file, line);
88 int option_chain_head_reference (ptr, bp, file, line)
89 struct option_chain_head **ptr;
90 struct option_chain_head *bp;
95 log_error ("%s(%d): null pointer", file, line);
96 #if defined (POINTER_DEBUG)
103 log_error ("%s(%d): non-null pointer", file, line);
104 #if defined (POINTER_DEBUG)
107 *ptr = (struct option_chain_head *)0;
112 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
116 int option_chain_head_dereference (ptr, file, line)
117 struct option_chain_head **ptr;
122 struct option_chain_head *option_chain_head;
126 log_error ("%s(%d): null pointer", file, line);
127 #if defined (POINTER_DEBUG)
134 option_chain_head = *ptr;
135 *ptr = (struct option_chain_head *)0;
136 --option_chain_head -> refcnt;
137 rc_register (file, line, ptr, option_chain_head,
138 option_chain_head -> refcnt, 1, RC_MISC);
139 if (option_chain_head -> refcnt > 0)
142 if (option_chain_head -> refcnt < 0) {
143 log_error ("%s(%d): negative refcnt!", file, line);
144 #if defined (DEBUG_RC_HISTORY)
145 dump_rc_history (option_chain_head);
147 #if defined (POINTER_DEBUG)
154 /* If there are any options on this head, free them. */
155 for (car = option_chain_head -> first; car; car = cdr) {
158 option_cache_dereference ((struct option_cache **)
164 dfree (option_chain_head, file, line);
168 int group_allocate (ptr, file, line)
177 log_error ("%s(%d): null pointer", file, line);
178 #if defined (POINTER_DEBUG)
185 log_error ("%s(%d): non-null pointer", file, line);
186 #if defined (POINTER_DEBUG)
189 *ptr = (struct group *)0;
193 g = dmalloc (sizeof *g, file, line);
195 memset (g, 0, sizeof *g);
196 return group_reference (ptr, g, file, line);
201 int group_reference (ptr, bp, file, line)
208 log_error ("%s(%d): null pointer", file, line);
209 #if defined (POINTER_DEBUG)
216 log_error ("%s(%d): non-null pointer", file, line);
217 #if defined (POINTER_DEBUG)
220 *ptr = (struct group *)0;
225 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
229 int group_dereference (ptr, file, line)
238 log_error ("%s(%d): null pointer", file, line);
239 #if defined (POINTER_DEBUG)
247 *ptr = (struct group *)0;
249 rc_register (file, line, ptr, group, group -> refcnt, 1, RC_MISC);
250 if (group -> refcnt > 0)
253 if (group -> refcnt < 0) {
254 log_error ("%s(%d): negative refcnt!", file, line);
255 #if defined (DEBUG_RC_HISTORY)
256 dump_rc_history (group);
258 #if defined (POINTER_DEBUG)
266 group_object_dereference (&group -> object, file, line);
268 subnet_dereference (&group -> subnet, file, line);
269 if (group -> shared_network)
270 shared_network_dereference (&group -> shared_network,
272 if (group -> statements)
273 executable_statement_dereference (&group -> statements,
276 group_dereference (&group -> next, file, line);
277 dfree (group, file, line);
281 struct dhcp_packet *new_dhcp_packet (file, line)
285 struct dhcp_packet *rval;
286 rval = (struct dhcp_packet *)dmalloc (sizeof (struct dhcp_packet),
291 struct protocol *new_protocol (file, line)
295 struct protocol *rval = dmalloc (sizeof (struct protocol), file, line);
299 struct domain_search_list *new_domain_search_list (file, line)
303 struct domain_search_list *rval =
304 dmalloc (sizeof (struct domain_search_list), file, line);
308 struct name_server *new_name_server (file, line)
312 struct name_server *rval =
313 dmalloc (sizeof (struct name_server), file, line);
317 void free_name_server (ptr, file, line)
318 struct name_server *ptr;
322 dfree ((VOIDPTR)ptr, file, line);
325 struct option *new_option (file, line)
329 struct option *rval =
330 dmalloc (sizeof (struct option), file, line);
332 memset (rval, 0, sizeof *rval);
336 void free_option (ptr, file, line)
341 /* XXX have to put all options on heap before this is possible. */
344 dfree ((VOIDPTR)option -> name, file, line);
345 dfree ((VOIDPTR)ptr, file, line);
349 struct universe *new_universe (file, line)
353 struct universe *rval =
354 dmalloc (sizeof (struct universe), file, line);
358 void free_universe (ptr, file, line)
359 struct universe *ptr;
363 dfree ((VOIDPTR)ptr, file, line);
366 void free_domain_search_list (ptr, file, line)
367 struct domain_search_list *ptr;
371 dfree ((VOIDPTR)ptr, file, line);
374 void free_protocol (ptr, file, line)
375 struct protocol *ptr;
379 dfree ((VOIDPTR)ptr, file, line);
382 void free_dhcp_packet (ptr, file, line)
383 struct dhcp_packet *ptr;
387 dfree ((VOIDPTR)ptr, file, line);
390 struct client_lease *new_client_lease (file, line)
394 return (struct client_lease *)dmalloc (sizeof (struct client_lease),
398 void free_client_lease (lease, file, line)
399 struct client_lease *lease;
403 dfree (lease, file, line);
408 pair new_pair (file, line)
416 free_pairs = foo -> cdr;
417 memset (foo, 0, sizeof *foo);
418 dmalloc_reuse (foo, file, line, 0);
422 foo = dmalloc (sizeof *foo, file, line);
425 memset (foo, 0, sizeof *foo);
429 void free_pair (foo, file, line)
434 foo -> cdr = free_pairs;
436 dmalloc_reuse (free_pairs, (char *)0, 0, 0);
439 #if defined (DEBUG_MEMORY_LEAKAGE) || \
440 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
441 void relinquish_free_pairs ()
445 for (pf = free_pairs; pf; pf = pc) {
449 free_pairs = (pair)0;
453 struct expression *free_expressions;
455 int expression_allocate (cptr, file, line)
456 struct expression **cptr;
460 struct expression *rval;
462 if (free_expressions) {
463 rval = free_expressions;
464 free_expressions = rval -> data.not;
465 dmalloc_reuse (rval, file, line, 1);
467 rval = dmalloc (sizeof (struct expression), file, line);
471 memset (rval, 0, sizeof *rval);
472 return expression_reference (cptr, rval, file, line);
475 int expression_reference (ptr, src, file, line)
476 struct expression **ptr;
477 struct expression *src;
482 log_error ("%s(%d): null pointer", file, line);
483 #if defined (POINTER_DEBUG)
490 log_error ("%s(%d): non-null pointer", file, line);
491 #if defined (POINTER_DEBUG)
494 *ptr = (struct expression *)0;
499 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
503 void free_expression (expr, file, line)
504 struct expression *expr;
508 expr -> data.not = free_expressions;
509 free_expressions = expr;
510 dmalloc_reuse (free_expressions, (char *)0, 0, 0);
513 #if defined (DEBUG_MEMORY_LEAKAGE) || \
514 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
515 void relinquish_free_expressions ()
517 struct expression *e, *n;
519 for (e = free_expressions; e; e = n) {
523 free_expressions = (struct expression *)0;
527 struct binding_value *free_binding_values;
529 int binding_value_allocate (cptr, file, line)
530 struct binding_value **cptr;
534 struct binding_value *rval;
536 if (free_binding_values) {
537 rval = free_binding_values;
538 free_binding_values = rval -> value.bv;
539 dmalloc_reuse (rval, file, line, 1);
541 rval = dmalloc (sizeof (struct binding_value), file, line);
545 memset (rval, 0, sizeof *rval);
546 return binding_value_reference (cptr, rval, file, line);
549 int binding_value_reference (ptr, src, file, line)
550 struct binding_value **ptr;
551 struct binding_value *src;
556 log_error ("%s(%d): null pointer", file, line);
557 #if defined (POINTER_DEBUG)
564 log_error ("%s(%d): non-null pointer", file, line);
565 #if defined (POINTER_DEBUG)
568 *ptr = (struct binding_value *)0;
573 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
577 void free_binding_value (bv, file, line)
578 struct binding_value *bv;
582 bv -> value.bv = free_binding_values;
583 free_binding_values = bv;
584 dmalloc_reuse (free_binding_values, (char *)0, 0, 0);
587 #if defined (DEBUG_MEMORY_LEAKAGE) || \
588 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
589 void relinquish_free_binding_values ()
591 struct binding_value *b, *n;
593 for (b = free_binding_values; b; b = n) {
597 free_binding_values = (struct binding_value *)0;
601 int fundef_allocate (cptr, file, line)
602 struct fundef **cptr;
608 rval = dmalloc (sizeof (struct fundef), file, line);
611 memset (rval, 0, sizeof *rval);
612 return fundef_reference (cptr, rval, file, line);
615 int fundef_reference (ptr, src, file, line)
622 log_error ("%s(%d): null pointer", file, line);
623 #if defined (POINTER_DEBUG)
630 log_error ("%s(%d): non-null pointer", file, line);
631 #if defined (POINTER_DEBUG)
634 *ptr = (struct fundef *)0;
639 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
643 struct option_cache *free_option_caches;
645 #if defined (DEBUG_MEMORY_LEAKAGE) || \
646 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
647 void relinquish_free_option_caches ()
649 struct option_cache *o, *n;
651 for (o = free_option_caches; o; o = n) {
652 n = (struct option_cache *)(o -> expression);
655 free_option_caches = (struct option_cache *)0;
659 int option_cache_allocate (cptr, file, line)
660 struct option_cache **cptr;
664 struct option_cache *rval;
666 if (free_option_caches) {
667 rval = free_option_caches;
669 (struct option_cache *)(rval -> expression);
670 dmalloc_reuse (rval, file, line, 0);
672 rval = dmalloc (sizeof (struct option_cache), file, line);
676 memset (rval, 0, sizeof *rval);
677 return option_cache_reference (cptr, rval, file, line);
680 int option_cache_reference (ptr, src, file, line)
681 struct option_cache **ptr;
682 struct option_cache *src;
687 log_error ("%s(%d): null pointer", file, line);
688 #if defined (POINTER_DEBUG)
695 log_error ("%s(%d): non-null pointer", file, line);
696 #if defined (POINTER_DEBUG)
699 *ptr = (struct option_cache *)0;
704 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
708 int buffer_allocate (ptr, len, file, line)
716 bp = dmalloc (len + sizeof *bp, file, line);
719 memset (bp, 0, sizeof *bp);
721 return buffer_reference (ptr, bp, file, line);
724 int buffer_reference (ptr, bp, file, line)
731 log_error ("%s(%d): null pointer", file, line);
732 #if defined (POINTER_DEBUG)
739 log_error ("%s(%d): non-null pointer", file, line);
740 #if defined (POINTER_DEBUG)
743 *ptr = (struct buffer *)0;
748 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
752 int buffer_dereference (ptr, file, line)
760 log_error ("%s(%d): null pointer", file, line);
761 #if defined (POINTER_DEBUG)
769 log_error ("%s(%d): null pointer", file, line);
770 #if defined (POINTER_DEBUG)
778 rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt, 1, RC_MISC);
779 if (!(*ptr) -> refcnt) {
780 dfree ((*ptr), file, line);
781 } else if ((*ptr) -> refcnt < 0) {
782 log_error ("%s(%d): negative refcnt!", file, line);
783 #if defined (DEBUG_RC_HISTORY)
784 dump_rc_history (*ptr);
786 #if defined (POINTER_DEBUG)
792 *ptr = (struct buffer *)0;
796 int dns_host_entry_allocate (ptr, hostname, file, line)
797 struct dns_host_entry **ptr;
798 const char *hostname;
802 struct dns_host_entry *bp;
804 bp = dmalloc (strlen (hostname) + sizeof *bp, file, line);
807 memset (bp, 0, sizeof *bp);
809 strcpy (bp -> hostname, hostname);
810 return dns_host_entry_reference (ptr, bp, file, line);
813 int dns_host_entry_reference (ptr, bp, file, line)
814 struct dns_host_entry **ptr;
815 struct dns_host_entry *bp;
820 log_error ("%s(%d): null pointer", file, line);
821 #if defined (POINTER_DEBUG)
828 log_error ("%s(%d): non-null pointer", file, line);
829 #if defined (POINTER_DEBUG)
832 *ptr = (struct dns_host_entry *)0;
837 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
841 int dns_host_entry_dereference (ptr, file, line)
842 struct dns_host_entry **ptr;
846 struct dns_host_entry *bp;
849 log_error ("%s(%d): null pointer", file, line);
850 #if defined (POINTER_DEBUG)
858 rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt, 1, RC_MISC);
859 if (!(*ptr) -> refcnt)
860 dfree ((*ptr), file, line);
861 if ((*ptr) -> refcnt < 0) {
862 log_error ("%s(%d): negative refcnt!", file, line);
863 #if defined (DEBUG_RC_HISTORY)
864 dump_rc_history (*ptr);
866 #if defined (POINTER_DEBUG)
872 *ptr = (struct dns_host_entry *)0;
876 int option_state_allocate (ptr, file, line)
877 struct option_state **ptr;
884 log_error ("%s(%d): null pointer", file, line);
885 #if defined (POINTER_DEBUG)
892 log_error ("%s(%d): non-null pointer", file, line);
893 #if defined (POINTER_DEBUG)
896 *ptr = (struct option_state *)0;
900 size = sizeof **ptr + (universe_count - 1) * sizeof (VOIDPTR);
901 *ptr = dmalloc (size, file, line);
903 memset (*ptr, 0, size);
904 (*ptr) -> universe_count = universe_count;
905 (*ptr) -> refcnt = 1;
906 rc_register (file, line,
907 ptr, *ptr, (*ptr) -> refcnt, 0, RC_MISC);
913 int option_state_reference (ptr, bp, file, line)
914 struct option_state **ptr;
915 struct option_state *bp;
920 log_error ("%s(%d): null pointer", file, line);
921 #if defined (POINTER_DEBUG)
928 log_error ("%s(%d): non-null pointer", file, line);
929 #if defined (POINTER_DEBUG)
932 *ptr = (struct option_state *)0;
937 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
941 int option_state_dereference (ptr, file, line)
942 struct option_state **ptr;
947 struct option_state *options;
950 log_error ("%s(%d): null pointer", file, line);
951 #if defined (POINTER_DEBUG)
959 *ptr = (struct option_state *)0;
961 rc_register (file, line, ptr, options, options -> refcnt, 1, RC_MISC);
962 if (options -> refcnt > 0)
965 if (options -> refcnt < 0) {
966 log_error ("%s(%d): negative refcnt!", file, line);
967 #if defined (DEBUG_RC_HISTORY)
968 dump_rc_history (options);
970 #if defined (POINTER_DEBUG)
977 /* Loop through the per-universe state. */
978 for (i = 0; i < options -> universe_count; i++)
979 if (options -> universes [i] &&
980 universes [i] -> option_state_dereference)
981 ((*(universes [i] -> option_state_dereference))
982 (universes [i], options, file, line));
983 dfree (options, file, line);
987 int executable_statement_allocate (ptr, file, line)
988 struct executable_statement **ptr;
992 struct executable_statement *bp;
994 bp = dmalloc (sizeof *bp, file, line);
997 memset (bp, 0, sizeof *bp);
998 return executable_statement_reference (ptr, bp, file, line);
1001 int executable_statement_reference (ptr, bp, file, line)
1002 struct executable_statement **ptr;
1003 struct executable_statement *bp;
1008 log_error ("%s(%d): null pointer", file, line);
1009 #if defined (POINTER_DEBUG)
1016 log_error ("%s(%d): non-null pointer", file, line);
1017 #if defined (POINTER_DEBUG)
1020 *ptr = (struct executable_statement *)0;
1025 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1029 static struct packet *free_packets;
1031 #if defined (DEBUG_MEMORY_LEAKAGE) || \
1032 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1033 void relinquish_free_packets ()
1035 struct packet *p, *n;
1036 for (p = free_packets; p; p = n) {
1037 n = (struct packet *)(p -> raw);
1040 free_packets = (struct packet *)0;
1044 int packet_allocate (ptr, file, line)
1045 struct packet **ptr;
1053 log_error ("%s(%d): null pointer", file, line);
1054 #if defined (POINTER_DEBUG)
1061 log_error ("%s(%d): non-null pointer", file, line);
1062 #if defined (POINTER_DEBUG)
1065 *ptr = (struct packet *)0;
1071 free_packets = (struct packet *)(p -> raw);
1072 dmalloc_reuse (p, file, line, 1);
1074 p = dmalloc (sizeof *p, file, line);
1077 memset (p, 0, sizeof *p);
1078 return packet_reference (ptr, p, file, line);
1083 int packet_reference (ptr, bp, file, line)
1084 struct packet **ptr;
1090 log_error ("%s(%d): null pointer", file, line);
1091 #if defined (POINTER_DEBUG)
1098 log_error ("%s(%d): non-null pointer", file, line);
1099 #if defined (POINTER_DEBUG)
1102 *ptr = (struct packet *)0;
1107 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1111 int packet_dereference (ptr, file, line)
1112 struct packet **ptr;
1117 struct packet *packet;
1119 if (!ptr || !*ptr) {
1120 log_error ("%s(%d): null pointer", file, line);
1121 #if defined (POINTER_DEBUG)
1129 *ptr = (struct packet *)0;
1131 rc_register (file, line, ptr, packet, packet -> refcnt, 1, RC_MISC);
1132 if (packet -> refcnt > 0)
1135 if (packet -> refcnt < 0) {
1136 log_error ("%s(%d): negative refcnt!", file, line);
1137 #if defined (DEBUG_RC_HISTORY)
1138 dump_rc_history (packet);
1140 #if defined (POINTER_DEBUG)
1147 if (packet -> options)
1148 option_state_dereference (&packet -> options, file, line);
1149 if (packet -> interface)
1150 interface_dereference (&packet -> interface, MDL);
1151 if (packet -> shared_network)
1152 shared_network_dereference (&packet -> shared_network, MDL);
1153 for (i = 0; i < packet -> class_count && i < PACKET_MAX_CLASSES; i++) {
1154 if (packet -> classes [i])
1155 omapi_object_dereference ((omapi_object_t **)
1156 &packet -> classes [i], MDL);
1158 packet -> raw = (struct dhcp_packet *)free_packets;
1159 free_packets = packet;
1160 dmalloc_reuse (free_packets, (char *)0, 0, 0);
1164 int dns_zone_allocate (ptr, file, line)
1165 struct dns_zone **ptr;
1173 log_error ("%s(%d): null pointer", file, line);
1174 #if defined (POINTER_DEBUG)
1181 log_error ("%s(%d): non-null pointer", file, line);
1182 #if defined (POINTER_DEBUG)
1185 *ptr = (struct dns_zone *)0;
1189 d = dmalloc (sizeof *d, file, line);
1191 memset (d, 0, sizeof *d);
1192 return dns_zone_reference (ptr, d, file, line);
1197 int dns_zone_reference (ptr, bp, file, line)
1198 struct dns_zone **ptr;
1199 struct dns_zone *bp;
1204 log_error ("%s(%d): null pointer", file, line);
1205 #if defined (POINTER_DEBUG)
1212 log_error ("%s(%d): non-null pointer", file, line);
1213 #if defined (POINTER_DEBUG)
1216 *ptr = (struct dns_zone *)0;
1221 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1225 int binding_scope_allocate (ptr, file, line)
1226 struct binding_scope **ptr;
1230 struct binding_scope *bp;
1233 log_error ("%s(%d): null pointer", file, line);
1234 #if defined (POINTER_DEBUG)
1242 log_error ("%s(%d): non-null pointer", file, line);
1243 #if defined (POINTER_DEBUG)
1250 bp = dmalloc (sizeof *bp, file, line);
1253 memset (bp, 0, sizeof *bp);
1254 binding_scope_reference (ptr, bp, file, line);
1258 int binding_scope_reference (ptr, bp, file, line)
1259 struct binding_scope **ptr;
1260 struct binding_scope *bp;
1265 log_error ("%s(%d): null pointer", file, line);
1266 #if defined (POINTER_DEBUG)
1273 log_error ("%s(%d): non-null pointer", file, line);
1274 #if defined (POINTER_DEBUG)
1277 *ptr = (struct binding_scope *)0;
1282 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1286 /* Make a copy of the data in data_string, upping the buffer reference
1287 count if there's a buffer. */
1289 void data_string_copy (dest, src, file, line)
1290 struct data_string *dest;
1291 struct data_string *src;
1296 buffer_reference (&dest -> buffer, src -> buffer, file, line);
1297 dest -> data = src -> data;
1298 dest -> terminated = src -> terminated;
1299 dest -> len = src -> len;
1302 /* Release the reference count to a data string's buffer (if any) and
1303 zero out the other information, yielding the null data string. */
1305 void data_string_forget (data, file, line)
1306 struct data_string *data;
1311 buffer_dereference (&data -> buffer, file, line);
1312 memset (data, 0, sizeof *data);
1315 /* Make a copy of the data in data_string, upping the buffer reference
1316 count if there's a buffer. */
1318 void data_string_truncate (dp, len)
1319 struct data_string *dp;
1322 if (len < dp -> len) {
1323 dp -> terminated = 0;