3 Memory allocation... */
6 * Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * Internet Systems Consortium, Inc.
23 * Redwood City, CA 94063
25 * https://www.isc.org/
27 * This software has been written for Internet Systems Consortium
28 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29 * To learn more about Internet Systems Consortium, see
30 * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
31 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32 * ``http://www.nominum.com''.
36 #include <omapip/omapip_p.h>
38 struct dhcp_packet *dhcp_free_list;
39 struct packet *packet_free_list;
41 int option_chain_head_allocate (ptr, file, line)
42 struct option_chain_head **ptr;
46 struct option_chain_head *h;
49 log_error ("%s(%d): null pointer", file, line);
50 #if defined (POINTER_DEBUG)
57 log_error ("%s(%d): non-null pointer", file, line);
58 #if defined (POINTER_DEBUG)
61 *ptr = (struct option_chain_head *)0;
65 h = dmalloc (sizeof *h, file, line);
67 memset (h, 0, sizeof *h);
68 return option_chain_head_reference (ptr, h, file, line);
73 int option_chain_head_reference (ptr, bp, file, line)
74 struct option_chain_head **ptr;
75 struct option_chain_head *bp;
80 log_error ("%s(%d): null pointer", file, line);
81 #if defined (POINTER_DEBUG)
88 log_error ("%s(%d): non-null pointer", file, line);
89 #if defined (POINTER_DEBUG)
92 *ptr = (struct option_chain_head *)0;
97 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
101 int option_chain_head_dereference (ptr, file, line)
102 struct option_chain_head **ptr;
106 struct option_chain_head *option_chain_head;
110 log_error ("%s(%d): null pointer", file, line);
111 #if defined (POINTER_DEBUG)
118 option_chain_head = *ptr;
119 *ptr = (struct option_chain_head *)0;
120 --option_chain_head -> refcnt;
121 rc_register (file, line, ptr, option_chain_head,
122 option_chain_head -> refcnt, 1, RC_MISC);
123 if (option_chain_head -> refcnt > 0)
126 if (option_chain_head -> refcnt < 0) {
127 log_error ("%s(%d): negative refcnt!", file, line);
128 #if defined (DEBUG_RC_HISTORY)
129 dump_rc_history (option_chain_head);
131 #if defined (POINTER_DEBUG)
138 /* If there are any options on this head, free them. */
139 for (car = option_chain_head -> first; car; car = cdr) {
142 option_cache_dereference ((struct option_cache **)
148 dfree (option_chain_head, file, line);
152 int group_allocate (ptr, file, line)
160 log_error ("%s(%d): null pointer", file, line);
161 #if defined (POINTER_DEBUG)
168 log_error ("%s(%d): non-null pointer", file, line);
169 #if defined (POINTER_DEBUG)
172 *ptr = (struct group *)0;
176 g = dmalloc (sizeof *g, file, line);
178 memset (g, 0, sizeof *g);
179 return group_reference (ptr, g, file, line);
184 int group_reference (ptr, bp, file, line)
191 log_error ("%s(%d): null pointer", file, line);
192 #if defined (POINTER_DEBUG)
199 log_error ("%s(%d): non-null pointer", file, line);
200 #if defined (POINTER_DEBUG)
203 *ptr = (struct group *)0;
208 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
212 int group_dereference (ptr, file, line)
220 log_error ("%s(%d): null pointer", file, line);
221 #if defined (POINTER_DEBUG)
229 *ptr = (struct group *)0;
231 rc_register (file, line, ptr, group, group -> refcnt, 1, RC_MISC);
232 if (group -> refcnt > 0)
235 if (group -> refcnt < 0) {
236 log_error ("%s(%d): negative refcnt!", file, line);
237 #if defined (DEBUG_RC_HISTORY)
238 dump_rc_history (group);
240 #if defined (POINTER_DEBUG)
248 group_object_dereference (&group -> object, file, line);
250 subnet_dereference (&group -> subnet, file, line);
251 if (group -> shared_network)
252 shared_network_dereference (&group -> shared_network,
254 if (group -> statements)
255 executable_statement_dereference (&group -> statements,
258 group_dereference (&group -> next, file, line);
259 dfree (group, file, line);
263 struct dhcp_packet *new_dhcp_packet (file, line)
267 struct dhcp_packet *rval;
268 rval = (struct dhcp_packet *)dmalloc (sizeof (struct dhcp_packet),
273 struct protocol *new_protocol (file, line)
277 struct protocol *rval = dmalloc (sizeof (struct protocol), file, line);
281 struct domain_search_list *new_domain_search_list (file, line)
285 struct domain_search_list *rval =
286 dmalloc (sizeof (struct domain_search_list), file, line);
290 struct name_server *new_name_server (file, line)
294 struct name_server *rval =
295 dmalloc (sizeof (struct name_server), file, line);
299 void free_name_server (ptr, file, line)
300 struct name_server *ptr;
304 dfree ((void *)ptr, file, line);
307 struct option *new_option (name, file, line)
317 rval = dmalloc(sizeof(struct option) + len + 1, file, line);
320 memcpy(rval + 1, name, len);
321 rval->name = (char *)(rval + 1);
327 struct universe *new_universe (file, line)
331 struct universe *rval =
332 dmalloc (sizeof (struct universe), file, line);
336 void free_universe (ptr, file, line)
337 struct universe *ptr;
341 dfree ((void *)ptr, file, line);
344 void free_domain_search_list (ptr, file, line)
345 struct domain_search_list *ptr;
349 dfree ((void *)ptr, file, line);
352 void free_protocol (ptr, file, line)
353 struct protocol *ptr;
357 dfree ((void *)ptr, file, line);
360 void free_dhcp_packet (ptr, file, line)
361 struct dhcp_packet *ptr;
365 dfree ((void *)ptr, file, line);
368 struct client_lease *new_client_lease (file, line)
372 return (struct client_lease *)dmalloc (sizeof (struct client_lease),
376 void free_client_lease (lease, file, line)
377 struct client_lease *lease;
381 dfree (lease, file, line);
386 pair new_pair (file, line)
394 free_pairs = foo -> cdr;
395 memset (foo, 0, sizeof *foo);
396 dmalloc_reuse (foo, file, line, 0);
400 foo = dmalloc (sizeof *foo, file, line);
403 memset (foo, 0, sizeof *foo);
407 void free_pair (foo, file, line)
412 foo -> cdr = free_pairs;
414 dmalloc_reuse (free_pairs, __FILE__, __LINE__, 0);
417 #if defined (DEBUG_MEMORY_LEAKAGE) || \
418 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
419 void relinquish_free_pairs ()
423 for (pf = free_pairs; pf; pf = pc) {
427 free_pairs = (pair)0;
431 struct expression *free_expressions;
433 int expression_allocate (cptr, file, line)
434 struct expression **cptr;
438 struct expression *rval;
440 if (free_expressions) {
441 rval = free_expressions;
442 free_expressions = rval -> data.not;
443 dmalloc_reuse (rval, file, line, 1);
445 rval = dmalloc (sizeof (struct expression), file, line);
449 memset (rval, 0, sizeof *rval);
450 return expression_reference (cptr, rval, file, line);
453 int expression_reference (ptr, src, file, line)
454 struct expression **ptr;
455 struct expression *src;
460 log_error ("%s(%d): null pointer", file, line);
461 #if defined (POINTER_DEBUG)
468 log_error ("%s(%d): non-null pointer", file, line);
469 #if defined (POINTER_DEBUG)
472 *ptr = (struct expression *)0;
477 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
481 void free_expression (expr, file, line)
482 struct expression *expr;
486 expr -> data.not = free_expressions;
487 free_expressions = expr;
488 dmalloc_reuse (free_expressions, __FILE__, __LINE__, 0);
491 #if defined (DEBUG_MEMORY_LEAKAGE) || \
492 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
493 void relinquish_free_expressions ()
495 struct expression *e, *n;
497 for (e = free_expressions; e; e = n) {
501 free_expressions = (struct expression *)0;
505 struct binding_value *free_binding_values;
507 int binding_value_allocate (cptr, file, line)
508 struct binding_value **cptr;
512 struct binding_value *rval;
514 if (free_binding_values) {
515 rval = free_binding_values;
516 free_binding_values = rval -> value.bv;
517 dmalloc_reuse (rval, file, line, 1);
519 rval = dmalloc (sizeof (struct binding_value), file, line);
523 memset (rval, 0, sizeof *rval);
524 return binding_value_reference (cptr, rval, file, line);
527 int binding_value_reference (ptr, src, file, line)
528 struct binding_value **ptr;
529 struct binding_value *src;
534 log_error ("%s(%d): null pointer", file, line);
535 #if defined (POINTER_DEBUG)
542 log_error ("%s(%d): non-null pointer", file, line);
543 #if defined (POINTER_DEBUG)
546 *ptr = (struct binding_value *)0;
551 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
555 void free_binding_value (bv, file, line)
556 struct binding_value *bv;
560 bv -> value.bv = free_binding_values;
561 free_binding_values = bv;
562 dmalloc_reuse (free_binding_values, (char *)0, 0, 0);
565 #if defined (DEBUG_MEMORY_LEAKAGE) || \
566 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
567 void relinquish_free_binding_values ()
569 struct binding_value *b, *n;
571 for (b = free_binding_values; b; b = n) {
575 free_binding_values = (struct binding_value *)0;
579 int fundef_allocate (cptr, file, line)
580 struct fundef **cptr;
586 rval = dmalloc (sizeof (struct fundef), file, line);
589 memset (rval, 0, sizeof *rval);
590 return fundef_reference (cptr, rval, file, line);
593 int fundef_reference (ptr, src, file, line)
600 log_error ("%s(%d): null pointer", file, line);
601 #if defined (POINTER_DEBUG)
608 log_error ("%s(%d): non-null pointer", file, line);
609 #if defined (POINTER_DEBUG)
612 *ptr = (struct fundef *)0;
617 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
621 struct option_cache *free_option_caches;
623 #if defined (DEBUG_MEMORY_LEAKAGE) || \
624 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
625 void relinquish_free_option_caches ()
627 struct option_cache *o, *n;
629 for (o = free_option_caches; o; o = n) {
630 n = (struct option_cache *)(o -> expression);
633 free_option_caches = (struct option_cache *)0;
637 int option_cache_allocate (cptr, file, line)
638 struct option_cache **cptr;
642 struct option_cache *rval;
644 if (free_option_caches) {
645 rval = free_option_caches;
647 (struct option_cache *)(rval -> expression);
648 dmalloc_reuse (rval, file, line, 0);
650 rval = dmalloc (sizeof (struct option_cache), file, line);
654 memset (rval, 0, sizeof *rval);
655 return option_cache_reference (cptr, rval, file, line);
658 int option_cache_reference (ptr, src, file, line)
659 struct option_cache **ptr;
660 struct option_cache *src;
665 log_error ("%s(%d): null pointer", file, line);
666 #if defined (POINTER_DEBUG)
673 log_error ("%s(%d): non-null pointer", file, line);
674 #if defined (POINTER_DEBUG)
677 *ptr = (struct option_cache *)0;
682 rc_register (file, line, ptr, src, src -> refcnt, 0, RC_MISC);
686 int buffer_allocate (ptr, len, file, line)
694 /* XXXSK: should check for bad ptr values, otherwise we
695 leak memory if they are wrong */
696 bp = dmalloc (len + sizeof *bp, file, line);
699 /* XXXSK: both of these initializations are unnecessary */
700 memset (bp, 0, sizeof *bp);
702 return buffer_reference (ptr, bp, file, line);
705 int buffer_reference (ptr, bp, file, line)
712 log_error ("%s(%d): null pointer", file, line);
713 #if defined (POINTER_DEBUG)
720 log_error ("%s(%d): non-null pointer", file, line);
721 #if defined (POINTER_DEBUG)
724 *ptr = (struct buffer *)0;
729 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
733 int buffer_dereference (ptr, file, line)
739 log_error ("%s(%d): null pointer", file, line);
740 #if defined (POINTER_DEBUG)
748 log_error ("%s(%d): null pointer", file, line);
749 #if defined (POINTER_DEBUG)
757 rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt, 1, RC_MISC);
758 if (!(*ptr) -> refcnt) {
759 dfree ((*ptr), file, line);
760 } else if ((*ptr) -> refcnt < 0) {
761 log_error ("%s(%d): negative refcnt!", file, line);
762 #if defined (DEBUG_RC_HISTORY)
763 dump_rc_history (*ptr);
765 #if defined (POINTER_DEBUG)
771 *ptr = (struct buffer *)0;
775 int dns_host_entry_allocate (ptr, hostname, file, line)
776 struct dns_host_entry **ptr;
777 const char *hostname;
781 struct dns_host_entry *bp;
783 bp = dmalloc (strlen (hostname) + sizeof *bp, file, line);
786 memset (bp, 0, sizeof *bp);
788 strcpy (bp -> hostname, hostname);
789 return dns_host_entry_reference (ptr, bp, file, line);
792 int dns_host_entry_reference (ptr, bp, file, line)
793 struct dns_host_entry **ptr;
794 struct dns_host_entry *bp;
799 log_error ("%s(%d): null pointer", file, line);
800 #if defined (POINTER_DEBUG)
807 log_error ("%s(%d): non-null pointer", file, line);
808 #if defined (POINTER_DEBUG)
811 *ptr = (struct dns_host_entry *)0;
816 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
820 int dns_host_entry_dereference (ptr, file, line)
821 struct dns_host_entry **ptr;
826 log_error ("%s(%d): null pointer", file, line);
827 #if defined (POINTER_DEBUG)
835 rc_register (file, line, ptr, *ptr, (*ptr) -> refcnt, 1, RC_MISC);
836 if (!(*ptr) -> refcnt)
837 dfree ((*ptr), file, line);
838 if ((*ptr) -> refcnt < 0) {
839 log_error ("%s(%d): negative refcnt!", file, line);
840 #if defined (DEBUG_RC_HISTORY)
841 dump_rc_history (*ptr);
843 #if defined (POINTER_DEBUG)
849 *ptr = (struct dns_host_entry *)0;
853 int option_state_allocate (ptr, file, line)
854 struct option_state **ptr;
861 log_error ("%s(%d): null pointer", file, line);
862 #if defined (POINTER_DEBUG)
869 log_error ("%s(%d): non-null pointer", file, line);
870 #if defined (POINTER_DEBUG)
873 *ptr = (struct option_state *)0;
877 size = sizeof **ptr + (universe_count - 1) * sizeof (void *);
878 *ptr = dmalloc (size, file, line);
880 memset (*ptr, 0, size);
881 (*ptr) -> universe_count = universe_count;
882 (*ptr) -> refcnt = 1;
883 rc_register (file, line,
884 ptr, *ptr, (*ptr) -> refcnt, 0, RC_MISC);
890 int option_state_reference (ptr, bp, file, line)
891 struct option_state **ptr;
892 struct option_state *bp;
897 log_error ("%s(%d): null pointer", file, line);
898 #if defined (POINTER_DEBUG)
905 log_error ("%s(%d): non-null pointer", file, line);
906 #if defined (POINTER_DEBUG)
909 *ptr = (struct option_state *)0;
914 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
918 int option_state_dereference (ptr, file, line)
919 struct option_state **ptr;
924 struct option_state *options;
927 log_error ("%s(%d): null pointer", file, line);
928 #if defined (POINTER_DEBUG)
936 *ptr = (struct option_state *)0;
938 rc_register (file, line, ptr, options, options -> refcnt, 1, RC_MISC);
939 if (options -> refcnt > 0)
942 if (options -> refcnt < 0) {
943 log_error ("%s(%d): negative refcnt!", file, line);
944 #if defined (DEBUG_RC_HISTORY)
945 dump_rc_history (options);
947 #if defined (POINTER_DEBUG)
954 /* Loop through the per-universe state. */
955 for (i = 0; i < options -> universe_count; i++)
956 if (options -> universes [i] &&
957 universes [i] -> option_state_dereference)
958 ((*(universes [i] -> option_state_dereference))
959 (universes [i], options, file, line));
961 dfree (options, file, line);
965 int executable_statement_allocate (ptr, file, line)
966 struct executable_statement **ptr;
970 struct executable_statement *bp;
972 bp = dmalloc (sizeof *bp, file, line);
975 memset (bp, 0, sizeof *bp);
976 return executable_statement_reference (ptr, bp, file, line);
979 int executable_statement_reference (ptr, bp, file, line)
980 struct executable_statement **ptr;
981 struct executable_statement *bp;
986 log_error ("%s(%d): null pointer", file, line);
987 #if defined (POINTER_DEBUG)
994 log_error ("%s(%d): non-null pointer", file, line);
995 #if defined (POINTER_DEBUG)
998 *ptr = (struct executable_statement *)0;
1003 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1007 static struct packet *free_packets;
1009 #if defined (DEBUG_MEMORY_LEAKAGE) || \
1010 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1011 void relinquish_free_packets ()
1013 struct packet *p, *n;
1014 for (p = free_packets; p; p = n) {
1015 n = (struct packet *)(p -> raw);
1018 free_packets = (struct packet *)0;
1022 int packet_allocate (ptr, file, line)
1023 struct packet **ptr;
1030 log_error ("%s(%d): null pointer", file, line);
1031 #if defined (POINTER_DEBUG)
1038 log_error ("%s(%d): non-null pointer", file, line);
1039 #if defined (POINTER_DEBUG)
1042 *ptr = (struct packet *)0;
1048 free_packets = (struct packet *)(p -> raw);
1049 dmalloc_reuse (p, file, line, 1);
1051 p = dmalloc (sizeof *p, file, line);
1054 memset (p, 0, sizeof *p);
1055 return packet_reference (ptr, p, file, line);
1060 int packet_reference (ptr, bp, file, line)
1061 struct packet **ptr;
1067 log_error ("%s(%d): null pointer", file, line);
1068 #if defined (POINTER_DEBUG)
1075 log_error ("%s(%d): non-null pointer", file, line);
1076 #if defined (POINTER_DEBUG)
1079 *ptr = (struct packet *)0;
1084 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1088 int packet_dereference (ptr, file, line)
1089 struct packet **ptr;
1094 struct packet *packet;
1096 if (!ptr || !*ptr) {
1097 log_error ("%s(%d): null pointer", file, line);
1098 #if defined (POINTER_DEBUG)
1106 *ptr = (struct packet *)0;
1108 rc_register (file, line, ptr, packet, packet -> refcnt, 1, RC_MISC);
1109 if (packet -> refcnt > 0)
1112 if (packet -> refcnt < 0) {
1113 log_error ("%s(%d): negative refcnt!", file, line);
1114 #if defined (DEBUG_RC_HISTORY)
1115 dump_rc_history (packet);
1117 #if defined (POINTER_DEBUG)
1124 if (packet -> options)
1125 option_state_dereference (&packet -> options, file, line);
1126 if (packet -> interface)
1127 interface_dereference (&packet -> interface, MDL);
1128 if (packet -> shared_network)
1129 shared_network_dereference (&packet -> shared_network, MDL);
1130 for (i = 0; i < packet -> class_count && i < PACKET_MAX_CLASSES; i++) {
1131 if (packet -> classes [i])
1132 omapi_object_dereference ((omapi_object_t **)
1133 &packet -> classes [i], MDL);
1135 packet -> raw = (struct dhcp_packet *)free_packets;
1136 free_packets = packet;
1137 dmalloc_reuse (free_packets, __FILE__, __LINE__, 0);
1141 int dns_zone_allocate (ptr, file, line)
1142 struct dns_zone **ptr;
1149 log_error ("%s(%d): null pointer", file, line);
1150 #if defined (POINTER_DEBUG)
1157 log_error ("%s(%d): non-null pointer", file, line);
1158 #if defined (POINTER_DEBUG)
1161 *ptr = (struct dns_zone *)0;
1165 d = dmalloc (sizeof *d, file, line);
1167 memset (d, 0, sizeof *d);
1168 return dns_zone_reference (ptr, d, file, line);
1173 int dns_zone_reference (ptr, bp, file, line)
1174 struct dns_zone **ptr;
1175 struct dns_zone *bp;
1180 log_error ("%s(%d): null pointer", file, line);
1181 #if defined (POINTER_DEBUG)
1188 log_error ("%s(%d): non-null pointer", file, line);
1189 #if defined (POINTER_DEBUG)
1192 *ptr = (struct dns_zone *)0;
1197 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1201 int binding_scope_allocate (ptr, file, line)
1202 struct binding_scope **ptr;
1206 struct binding_scope *bp;
1209 log_error ("%s(%d): null pointer", file, line);
1210 #if defined (POINTER_DEBUG)
1218 log_error ("%s(%d): non-null pointer", file, line);
1219 #if defined (POINTER_DEBUG)
1226 bp = dmalloc (sizeof *bp, file, line);
1229 memset (bp, 0, sizeof *bp);
1230 binding_scope_reference (ptr, bp, file, line);
1234 int binding_scope_reference (ptr, bp, file, line)
1235 struct binding_scope **ptr;
1236 struct binding_scope *bp;
1241 log_error ("%s(%d): null pointer", file, line);
1242 #if defined (POINTER_DEBUG)
1249 log_error ("%s(%d): non-null pointer", file, line);
1250 #if defined (POINTER_DEBUG)
1253 *ptr = (struct binding_scope *)0;
1258 rc_register (file, line, ptr, bp, bp -> refcnt, 0, RC_MISC);
1262 /* Make a copy of the data in data_string, upping the buffer reference
1263 count if there's a buffer. */
1266 data_string_copy(struct data_string *dest, const struct data_string *src,
1267 const char *file, int line)
1269 if (src -> buffer) {
1270 buffer_reference (&dest -> buffer, src -> buffer, file, line);
1272 dest->buffer = NULL;
1274 dest -> data = src -> data;
1275 dest -> terminated = src -> terminated;
1276 dest -> len = src -> len;
1279 /* Release the reference count to a data string's buffer (if any) and
1280 zero out the other information, yielding the null data string. */
1282 void data_string_forget (data, file, line)
1283 struct data_string *data;
1288 buffer_dereference (&data -> buffer, file, line);
1289 memset (data, 0, sizeof *data);
1292 /* If the data_string is larger than the specified length, reduce
1293 the data_string to the specified size. */
1295 void data_string_truncate (dp, len)
1296 struct data_string *dp;
1299 /* XXX: do we need to consider the "terminated" flag in the check? */
1300 if (len < dp -> len) {
1301 dp -> terminated = 0;