X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Felhash.c;h=b034860f0bac2df5b2e84747730674ffd9a4ba76;hb=8ba221d9742198c8d3d2d7ba3f4a7730e551afef;hp=8677f953a60f07338524a7e7886c4326d081b1c5;hpb=0c693dc08f0794304711787b2eb47c144ea4bef1;p=chise%2Fxemacs-chise.git.1 diff --git a/src/elhash.c b/src/elhash.c index 8677f95..b034860 100644 --- a/src/elhash.c +++ b/src/elhash.c @@ -500,13 +500,7 @@ make_general_lisp_hash_table (hash_table_hash_function_t hash_function, compute_hash_table_derived_values (ht); /* We leave room for one never-occupied sentinel hentry at the end. */ - ht->hentries = xnew_array (hentry, ht->size + 1); - - { - hentry *e, *sentinel; - for (e = ht->hentries, sentinel = e + ht->size; e <= sentinel; e++) - CLEAR_HENTRY (e); - } + ht->hentries = xnew_array_and_zero (hentry, ht->size + 1); XSETHASH_TABLE (hash_table, ht); @@ -1207,6 +1201,19 @@ may remhash or puthash the entry currently being processed by FUNCTION. return Qnil; } +/* #### If the Lisp function being called does a puthash and this + #### causes the hash table to be resized, the results will be quite + #### random and we will likely crash. To fix this, either set a + #### flag in the hash table while we're mapping and signal an error + #### when new entries are added, or fix things to make this + #### operation work properly, like this: Store two hash tables in + #### each hash table object -- the second one is written to when + #### you do a puthash inside of a mapping operation, and the + #### various operations need to check both hash tables for entries. + #### As soon as the last maphash over a particular hash table + #### object terminates, the entries in the second table are added + #### to the first (using an unwind-protect). --ben */ + /* Map *C* function FUNCTION over the elements of a lisp hash table. */ void elisp_maphash (maphash_function_t function,