Mercurial > hg > xemacs-beta
comparison src/elhash.c @ 207:e45d5e7c476e r20-4b2
Import from CVS: tag r20-4b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:03:52 +0200 |
parents | a2f645c6b9f8 |
children | 78478c60bfcd |
comparison
equal
deleted
inserted
replaced
206:d3e9274cbc4e | 207:e45d5e7c476e |
---|---|
97 int len = XVECTOR_LENGTH (ht->harray); | 97 int len = XVECTOR_LENGTH (ht->harray); |
98 | 98 |
99 c_table->harray = (hentry *) XVECTOR_DATA (ht->harray); | 99 c_table->harray = (hentry *) XVECTOR_DATA (ht->harray); |
100 c_table->zero_set = (!GC_UNBOUNDP (ht->zero_entry)); | 100 c_table->zero_set = (!GC_UNBOUNDP (ht->zero_entry)); |
101 c_table->zero_entry = LISP_TO_VOID (ht->zero_entry); | 101 c_table->zero_entry = LISP_TO_VOID (ht->zero_entry); |
102 #ifndef LRECORD_VECTOR | |
102 if (len < 0) | 103 if (len < 0) |
103 { | 104 { |
104 /* #### if alloc.c mark_object() changes, this must change too. */ | 105 /* #### if alloc.c mark_object() changes, this must change too. */ |
105 /* barf gag retch. When a vector is marked, its len is | 106 /* barf gag retch. When a vector is marked, its len is |
106 made less than 0. In the prune_weak_hashtables() stage, | 107 made less than 0. In the prune_weak_hashtables() stage, |
107 we are called on vectors that are like this, and we must | 108 we are called on vectors that are like this, and we must |
108 be able to deal. */ | 109 be able to deal. */ |
109 assert (gc_in_progress); | 110 assert (gc_in_progress); |
110 len = -1 - len; | 111 len = -1 - len; |
111 } | 112 } |
113 #endif | |
112 c_table->size = len/LISP_OBJECTS_PER_HENTRY; | 114 c_table->size = len/LISP_OBJECTS_PER_HENTRY; |
113 c_table->fullness = ht->fullness; | 115 c_table->fullness = ht->fullness; |
114 c_table->hash_function = ht->hash_function; | 116 c_table->hash_function = ht->hash_function; |
115 c_table->test_function = ht->test_function; | 117 c_table->test_function = ht->test_function; |
116 XSETHASHTABLE (c_table->elisp_table, ht); | 118 XSETHASHTABLE (c_table->elisp_table, ht); |
152 { | 154 { |
153 Lisp_Object new_vector; | 155 Lisp_Object new_vector; |
154 struct hashtable *ht = XHASHTABLE (table); | 156 struct hashtable *ht = XHASHTABLE (table); |
155 | 157 |
156 assert (bytes > XVECTOR_LENGTH (ht->harray) * sizeof (Lisp_Object)); | 158 assert (bytes > XVECTOR_LENGTH (ht->harray) * sizeof (Lisp_Object)); |
157 new_vector = make_vector ((bytes / sizeof (Lisp_Object)), Qzero); | 159 new_vector = make_vector ((bytes / sizeof (Lisp_Object)), Qnull_pointer); |
158 return (void *) XVECTOR_DATA (new_vector); | 160 return (void *) XVECTOR_DATA (new_vector); |
159 } | 161 } |
160 | 162 |
161 void | 163 void |
162 elisp_hvector_free (void *ptr, Lisp_Object table) | 164 elisp_hvector_free (void *ptr, Lisp_Object table) |
250 Lisp_Object result; | 252 Lisp_Object result; |
251 struct hashtable *table = allocate_hashtable (); | 253 struct hashtable *table = allocate_hashtable (); |
252 | 254 |
253 table->harray = make_vector ((compute_harray_size (size) | 255 table->harray = make_vector ((compute_harray_size (size) |
254 * LISP_OBJECTS_PER_HENTRY), | 256 * LISP_OBJECTS_PER_HENTRY), |
255 Qzero); | 257 Qnull_pointer); |
256 switch (test) | 258 switch (test) |
257 { | 259 { |
258 case HASHTABLE_EQ: | 260 case HASHTABLE_EQ: |
259 table->test_function = NULL; | 261 table->test_function = NULL; |
260 table->hash_function = NULL; | 262 table->hash_function = NULL; |
339 new_ht = allocate_hashtable (); | 341 new_ht = allocate_hashtable (); |
340 new_ht->fullness = 0; | 342 new_ht->fullness = 0; |
341 new_ht->zero_entry = Qunbound; | 343 new_ht->zero_entry = Qunbound; |
342 new_ht->hash_function = old_ht->hash_function; | 344 new_ht->hash_function = old_ht->hash_function; |
343 new_ht->test_function = old_ht->test_function; | 345 new_ht->test_function = old_ht->test_function; |
344 new_ht->harray = Fmake_vector (Flength (old_ht->harray), Qzero); | 346 new_ht->harray = Fmake_vector (Flength (old_ht->harray), Qnull_pointer); |
345 ht_copy_to_c (new_ht, &new_htbl); | 347 ht_copy_to_c (new_ht, &new_htbl); |
346 copy_hash (&new_htbl, &old_htbl); | 348 copy_hash (&new_htbl, &old_htbl); |
347 ht_copy_from_c (&new_htbl, new_ht); | 349 ht_copy_from_c (&new_htbl, new_ht); |
348 new_ht->type = old_ht->type; | 350 new_ht->type = old_ht->type; |
349 XSETHASHTABLE (result, new_ht); | 351 XSETHASHTABLE (result, new_ht); |
714 we just need to prevent the vector itself from disappearing.) | 716 we just need to prevent the vector itself from disappearing.) |
715 (The remhash above has taken care of zero_entry.) | 717 (The remhash above has taken care of zero_entry.) |
716 */ | 718 */ |
717 struct Lisp_Vector *ptr = XVECTOR (XHASHTABLE (rest)->harray); | 719 struct Lisp_Vector *ptr = XVECTOR (XHASHTABLE (rest)->harray); |
718 int len = vector_length (ptr); | 720 int len = vector_length (ptr); |
721 #ifdef LRECORD_VECTOR | |
722 if (! MARKED_RECORD_P(XHASHTABLE(rest)->harray)) | |
723 { | |
724 MARK_RECORD_HEADER(&(ptr->header.lheader)); | |
725 did_mark = 1; | |
726 } | |
727 #else | |
719 if (len >= 0) | 728 if (len >= 0) |
720 { | 729 { |
721 ptr->size = -1 - len; | 730 ptr->size = -1 - len; |
722 did_mark = 1; | 731 did_mark = 1; |
723 } | 732 } |
733 #endif | |
724 /* else it's already marked (remember, this function is iterated | 734 /* else it's already marked (remember, this function is iterated |
725 until marking stops) */ | 735 until marking stops) */ |
726 } | 736 } |
727 } | 737 } |
728 | 738 |
828 return HASH2 (internal_hash (XCAR (obj), depth + 1), | 838 return HASH2 (internal_hash (XCAR (obj), depth + 1), |
829 internal_hash (XCDR (obj), depth + 1)); | 839 internal_hash (XCDR (obj), depth + 1)); |
830 } | 840 } |
831 else if (STRINGP (obj)) | 841 else if (STRINGP (obj)) |
832 return hash_string (XSTRING_DATA (obj), XSTRING_LENGTH (obj)); | 842 return hash_string (XSTRING_DATA (obj), XSTRING_LENGTH (obj)); |
833 #ifndef LRECORD_VECTOR | |
834 else if (VECTORP (obj)) | 843 else if (VECTORP (obj)) |
835 { | 844 { |
836 struct Lisp_Vector *v = XVECTOR (obj); | 845 struct Lisp_Vector *v = XVECTOR (obj); |
837 return HASH2 (vector_length (v), | 846 return HASH2 (vector_length (v), |
838 internal_array_hash (v->contents, vector_length (v), | 847 internal_array_hash (v->contents, vector_length (v), |
839 depth + 1)); | 848 depth + 1)); |
840 } | 849 } |
841 #endif /* !LRECORD_VECTOR */ | |
842 else if (LRECORDP (obj)) | 850 else if (LRECORDP (obj)) |
843 { | 851 { |
844 CONST struct lrecord_implementation | 852 CONST struct lrecord_implementation |
845 *imp = XRECORD_LHEADER (obj)->implementation; | 853 *imp = XRECORD_LHEADER (obj)->implementation; |
846 if (imp->hash) | 854 if (imp->hash) |