Mercurial > hg > xemacs-beta
comparison src/elhash.c @ 5117:3742ea8250b5 ben-lisp-object ben-lisp-object-final-ws-year-2005
Checking in final CVS version of workspace 'ben-lisp-object'
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 00:20:27 -0600 |
parents | 1e7cc382eb16 |
children | e0db3c197671 |
comparison
equal
deleted
inserted
replaced
5116:e56f73345619 | 5117:3742ea8250b5 |
---|---|
470 { &htentry_union_description } }, | 470 { &htentry_union_description } }, |
471 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) }, | 471 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) }, |
472 { XD_END } | 472 { XD_END } |
473 }; | 473 }; |
474 | 474 |
475 DEFINE_LRECORD_IMPLEMENTATION ("hash-table", hash_table, | 475 DEFINE_LISP_OBJECT ("hash-table", hash_table, |
476 1, /*dumpable-flag*/ | 476 mark_hash_table, print_hash_table, |
477 mark_hash_table, print_hash_table, | |
478 finalize_hash_table, | 477 finalize_hash_table, |
479 hash_table_equal, hash_table_hash, | 478 hash_table_equal, hash_table_hash, |
480 hash_table_description, | 479 hash_table_description, |
481 Lisp_Hash_Table); | 480 Lisp_Hash_Table); |
482 | 481 |
547 Elemcount size, | 546 Elemcount size, |
548 double rehash_size, | 547 double rehash_size, |
549 double rehash_threshold, | 548 double rehash_threshold, |
550 enum hash_table_weakness weakness) | 549 enum hash_table_weakness weakness) |
551 { | 550 { |
552 Lisp_Object hash_table; | 551 Lisp_Object hash_table = ALLOC_LISP_OBJECT (hash_table); |
553 Lisp_Hash_Table *ht = ALLOC_LCRECORD_TYPE (Lisp_Hash_Table, &lrecord_hash_table); | 552 Lisp_Hash_Table *ht = XHASH_TABLE (hash_table); |
554 | 553 |
555 ht->test_function = test_function; | 554 ht->test_function = test_function; |
556 ht->hash_function = hash_function; | 555 ht->hash_function = hash_function; |
557 ht->weakness = weakness; | 556 ht->weakness = weakness; |
558 | 557 |
571 | 570 |
572 compute_hash_table_derived_values (ht); | 571 compute_hash_table_derived_values (ht); |
573 | 572 |
574 /* We leave room for one never-occupied sentinel htentry at the end. */ | 573 /* We leave room for one never-occupied sentinel htentry at the end. */ |
575 ht->hentries = xnew_array_and_zero (htentry, ht->size + 1); | 574 ht->hentries = xnew_array_and_zero (htentry, ht->size + 1); |
576 | |
577 hash_table = wrap_hash_table (ht); | |
578 | 575 |
579 if (weakness == HASH_TABLE_NON_WEAK) | 576 if (weakness == HASH_TABLE_NON_WEAK) |
580 ht->next_weak = Qunbound; | 577 ht->next_weak = Qunbound; |
581 else | 578 else |
582 ht->next_weak = Vall_weak_hash_tables, Vall_weak_hash_tables = hash_table; | 579 ht->next_weak = Vall_weak_hash_tables, Vall_weak_hash_tables = hash_table; |
965 The keys and values will not themselves be copied. | 962 The keys and values will not themselves be copied. |
966 */ | 963 */ |
967 (hash_table)) | 964 (hash_table)) |
968 { | 965 { |
969 const Lisp_Hash_Table *ht_old = xhash_table (hash_table); | 966 const Lisp_Hash_Table *ht_old = xhash_table (hash_table); |
970 Lisp_Hash_Table *ht = ALLOC_LCRECORD_TYPE (Lisp_Hash_Table, &lrecord_hash_table); | 967 Lisp_Object obj = ALLOC_LISP_OBJECT (hash_table); |
968 Lisp_Hash_Table *ht = XHASH_TABLE (obj); | |
971 COPY_LCRECORD (ht, ht_old); | 969 COPY_LCRECORD (ht, ht_old); |
972 | 970 |
973 ht->hentries = xnew_array (htentry, ht_old->size + 1); | 971 ht->hentries = xnew_array (htentry, ht_old->size + 1); |
974 memcpy (ht->hentries, ht_old->hentries, (ht_old->size + 1) * sizeof (htentry)); | 972 memcpy (ht->hentries, ht_old->hentries, (ht_old->size + 1) * sizeof (htentry)); |
975 | 973 |
976 hash_table = wrap_hash_table (ht); | |
977 | |
978 if (! EQ (ht->next_weak, Qunbound)) | 974 if (! EQ (ht->next_weak, Qunbound)) |
979 { | 975 { |
980 ht->next_weak = Vall_weak_hash_tables; | 976 ht->next_weak = Vall_weak_hash_tables; |
981 Vall_weak_hash_tables = hash_table; | 977 Vall_weak_hash_tables = obj; |
982 } | 978 } |
983 | 979 |
984 return hash_table; | 980 return obj; |
985 } | 981 } |
986 | 982 |
987 static void | 983 static void |
988 resize_hash_table (Lisp_Hash_Table *ht, Elemcount new_size) | 984 resize_hash_table (Lisp_Hash_Table *ht, Elemcount new_size) |
989 { | 985 { |
1758 } | 1754 } |
1759 | 1755 |
1760 void | 1756 void |
1761 init_elhash_once_early (void) | 1757 init_elhash_once_early (void) |
1762 { | 1758 { |
1763 INIT_LRECORD_IMPLEMENTATION (hash_table); | 1759 INIT_LISP_OBJECT (hash_table); |
1764 | 1760 |
1765 /* This must NOT be staticpro'd */ | 1761 /* This must NOT be staticpro'd */ |
1766 Vall_weak_hash_tables = Qnil; | 1762 Vall_weak_hash_tables = Qnil; |
1767 dump_add_weak_object_chain (&Vall_weak_hash_tables); | 1763 dump_add_weak_object_chain (&Vall_weak_hash_tables); |
1768 } | 1764 } |