comparison src/alloc.c @ 32587:b3918817f15f

(mark_object) [GC_CHECK_STRING_BYTES]: Check validity of string's size_byte. (check_string_bytes) [GC_CHECK_STRING_BYTES]: New function. (check_string_bytes_count) [GC_CHECK_STRING_BYTES]: New variable. (allocate_string) [GC_CHECK_STRING_BYTES]: Call it for every 10th string allocated.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 17 Oct 2000 15:38:30 +0000
parents d8b668a486d7
children e0646c73bf81
comparison
equal deleted inserted replaced
32586:40cebc20f02c 32587:b3918817f15f
1019 n_string_blocks = 0; 1019 n_string_blocks = 0;
1020 string_free_list = NULL; 1020 string_free_list = NULL;
1021 } 1021 }
1022 1022
1023 1023
1024 #ifdef GC_CHECK_STRING_BYTES
1025
1026 /* Check validity of all live Lisp strings' string_bytes member.
1027 Used for hunting a bug. */
1028
1029 static int check_string_bytes_count;
1030
1031 void
1032 check_string_bytes ()
1033 {
1034 struct sblock *b;
1035
1036 for (b = large_sblocks; b; b = b->next)
1037 {
1038 struct Lisp_String *s = b->first_data.string;
1039 if (s && GC_STRING_BYTES (s) != SDATA_NBYTES (SDATA_OF_STRING (s)))
1040 abort ();
1041 }
1042
1043 for (b = oldest_sblock; b; b = b->next)
1044 {
1045 struct sdata *from, *end, *from_end;
1046
1047 end = b->next_free;
1048
1049 for (from = &b->first_data; from < end; from = from_end)
1050 {
1051 /* Compute the next FROM here because copying below may
1052 overwrite data we need to compute it. */
1053 int nbytes;
1054
1055 /* Check that the string size recorded in the string is the
1056 same as the one recorded in the sdata structure. */
1057 if (from->string
1058 && GC_STRING_BYTES (from->string) != SDATA_NBYTES (from))
1059 abort ();
1060
1061 if (from->string)
1062 nbytes = GC_STRING_BYTES (from->string);
1063 else
1064 nbytes = SDATA_NBYTES (from);
1065
1066 nbytes = SDATA_SIZE (nbytes);
1067 from_end = (struct sdata *) ((char *) from + nbytes);
1068 }
1069 }
1070 }
1071
1072 #endif /* GC_CHECK_STRING_BYTES */
1073
1074
1024 /* Return a new Lisp_String. */ 1075 /* Return a new Lisp_String. */
1025 1076
1026 static struct Lisp_String * 1077 static struct Lisp_String *
1027 allocate_string () 1078 allocate_string ()
1028 { 1079 {
1061 1112
1062 --total_free_strings; 1113 --total_free_strings;
1063 ++total_strings; 1114 ++total_strings;
1064 ++strings_consed; 1115 ++strings_consed;
1065 consing_since_gc += sizeof *s; 1116 consing_since_gc += sizeof *s;
1117
1118 #ifdef GC_CHECK_STRING_BYTES
1119 if (++check_string_bytes_count == 10)
1120 {
1121 check_string_bytes_count = 0;
1122 check_string_bytes ();
1123 }
1124 #endif
1066 1125
1067 return s; 1126 return s;
1068 } 1127 }
1069 1128
1070 1129
3926 { 3985 {
3927 register struct Lisp_String *ptr = XSTRING (obj); 3986 register struct Lisp_String *ptr = XSTRING (obj);
3928 CHECK_ALLOCATED_AND_LIVE (live_string_p); 3987 CHECK_ALLOCATED_AND_LIVE (live_string_p);
3929 MARK_INTERVAL_TREE (ptr->intervals); 3988 MARK_INTERVAL_TREE (ptr->intervals);
3930 MARK_STRING (ptr); 3989 MARK_STRING (ptr);
3990 #ifdef GC_CHECK_STRING_BYTES
3991 {
3992 /* Check that the string size recorded in the string is the
3993 same as the one recorded in the sdata structure. */
3994 struct sdata *p = SDATA_OF_STRING (ptr);
3995 if (GC_STRING_BYTES (ptr) != SDATA_NBYTES (p))
3996 abort ();
3997 }
3998 #endif /* GC_CHECK_STRING_BYTES */
3931 } 3999 }
3932 break; 4000 break;
3933 4001
3934 case Lisp_Vectorlike: 4002 case Lisp_Vectorlike:
3935 #ifdef GC_CHECK_MARKED_OBJECTS 4003 #ifdef GC_CHECK_MARKED_OBJECTS