Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

emptying hash tables



-----BEGIN PGP SIGNED MESSAGE-----

This patch adds a generic emptytable method, that just removes all the
hash nodes.  This avoids the need for auxilliary functions that just
call emptyhashtable(), and generally gets that unused resizing interface
out of the way.

 -zefram

      *** Src/hashtable.c	1996/12/26 19:13:27	1.18
      --- Src/hashtable.c	1997/01/01 06:39:20
      ***************
      *** 461,467 ****
        
        /**/
        void
      ! emptyhashtable(HashTable ht, int newsize)
        {
            struct hashnode **ha, *hn, *hp;
            int i;
      --- 461,467 ----
        
        /**/
        void
      ! resizehashtable(HashTable ht, int newsize)
        {
            struct hashnode **ha, *hn, *hp;
            int i;
      ***************
      *** 490,495 ****
      --- 490,504 ----
            ht->ct = 0;
        }
        
      + /* Generic method to empty a hash table */
      + 
      + /**/
      + void
      + emptyhashtable(HashTable ht)
      + {
      +     resizehashtable(ht, ht->hsize);
      + }
      + 
        #ifdef ZSH_HASH_DEBUG
        
        /* Print info about hash table */
      ***************
      *** 547,562 ****
        /* Command Hash Table Functions */
        /********************************/
        
      - /* size of the initial cmdnamtab hash table */
      - #define INITIAL_CMDNAMTAB 201
      - 
        /* Create a new command hash table */
         
        /**/
        void
        createcmdnamtable(void)
        {
      !     cmdnamtab = newhashtable(INITIAL_CMDNAMTAB, "cmdnamtab", NULL);
        
            cmdnamtab->hash        = hasher;
            cmdnamtab->emptytable  = emptycmdnamtable;
      --- 556,568 ----
        /* Command Hash Table Functions */
        /********************************/
        
        /* Create a new command hash table */
         
        /**/
        void
        createcmdnamtable(void)
        {
      !     cmdnamtab = newhashtable(201, "cmdnamtab", NULL);
        
            cmdnamtab->hash        = hasher;
            cmdnamtab->emptytable  = emptycmdnamtable;
      ***************
      *** 577,583 ****
        void
        emptycmdnamtable(HashTable ht)
        {
      !     emptyhashtable(ht, INITIAL_CMDNAMTAB);
            pathchecked = path;
        }
        
      --- 583,589 ----
        void
        emptycmdnamtable(HashTable ht)
        {
      !     emptyhashtable(ht);
            pathchecked = path;
        }
        
      ***************
      *** 1141,1152 ****
        /* Named Directory Hash Table Functions */
        /****************************************/
        
      - /* size of the initial name directory hash table */
      - #define INITIAL_NAMEDDIR 201
      - 
        /* != 0 if all the usernames have already been *
         * added to the named directory hash table.    */
      ! int allusersadded;
        
        /* Create new hash table for named directories */
        
      --- 1147,1155 ----
        /* Named Directory Hash Table Functions */
        /****************************************/
        
        /* != 0 if all the usernames have already been *
         * added to the named directory hash table.    */
      ! static int allusersadded;
        
        /* Create new hash table for named directories */
        
      ***************
      *** 1154,1160 ****
        void
        createnameddirtable(void)
        {
      !     nameddirtab = newhashtable(INITIAL_NAMEDDIR, "nameddirtab", NULL);
        
            nameddirtab->hash        = hasher;
            nameddirtab->emptytable  = emptynameddirtable;
      --- 1157,1163 ----
        void
        createnameddirtable(void)
        {
      !     nameddirtab = newhashtable(201, "nameddirtab", NULL);
        
            nameddirtab->hash        = hasher;
            nameddirtab->emptytable  = emptynameddirtable;
      ***************
      *** 1178,1184 ****
        void
        emptynameddirtable(HashTable ht)
        {
      !     emptyhashtable(ht, INITIAL_NAMEDDIR);
            allusersadded = 0;
            finddir(NULL);		/* clear the finddir cache */
        }
      --- 1181,1187 ----
        void
        emptynameddirtable(HashTable ht)
        {
      !     emptyhashtable(ht);
            allusersadded = 0;
            finddir(NULL);		/* clear the finddir cache */
        }
      *** Src/Zle/zle_keymap.c	1996/12/26 19:13:33	1.1
      --- Src/Zle/zle_keymap.c	1997/01/01 06:42:53
      ***************
      *** 110,121 ****
        /* local functions */
        
        static void createkeymapnamtab _((void));
      - static void emptykeymapnamtab _((HashTable));
        static KeymapName makekeymapnamnode _((Keymap));
        static void freekeymapnamnode _((HashNode));
        
        static HashTable newkeytab _((char *));
      - static void emptykeytab _((HashTable));
        static Key makekeynode _((int, char *));
        static void freekeynode _((HashNode));
        
      --- 110,119 ----
      ***************
      *** 147,162 ****
        /* hashtable management functions */
        /**********************************/
        
      - #define INITIAL_KEYMAPNAMTAB  7
      - #define INITIAL_KEYTAB       19
      - 
        static void
        createkeymapnamtab(void)
        {
      !     keymapnamtab = newhashtable(INITIAL_KEYMAPNAMTAB, "keymapnamtab", NULL);
        
            keymapnamtab->hash        = hasher;
      !     keymapnamtab->emptytable  = emptykeymapnamtab;
            keymapnamtab->filltable   = NULL;
            keymapnamtab->addnode     = addhashnode;
            keymapnamtab->getnode     = gethashnode2;
      --- 145,157 ----
        /* hashtable management functions */
        /**********************************/
        
        static void
        createkeymapnamtab(void)
        {
      !     keymapnamtab = newhashtable(7, "keymapnamtab", NULL);
        
            keymapnamtab->hash        = hasher;
      !     keymapnamtab->emptytable  = emptyhashtable;
            keymapnamtab->filltable   = NULL;
            keymapnamtab->addnode     = addhashnode;
            keymapnamtab->getnode     = gethashnode2;
      ***************
      *** 168,179 ****
            keymapnamtab->printnode   = NULL;
        }
        
      - static void
      - emptykeymapnamtab(HashTable ht)
      - {
      -     emptyhashtable(ht, INITIAL_KEYMAPNAMTAB);
      - }
      - 
        static KeymapName
        makekeymapnamnode(Keymap keymap)
        {
      --- 163,168 ----
      ***************
      *** 197,207 ****
        static HashTable
        newkeytab(char *kmname)
        {
      !     HashTable ht = newhashtable(INITIAL_KEYTAB,
        	kmname ?  dyncat("keytab:", kmname) : "keytab:", NULL);
        
            ht->hash        = hasher;
      !     ht->emptytable  = emptykeytab;
            ht->filltable   = NULL;
            ht->addnode     = addhashnode;
            ht->getnode     = gethashnode2;
      --- 186,196 ----
        static HashTable
        newkeytab(char *kmname)
        {
      !     HashTable ht = newhashtable(19,
        	kmname ?  dyncat("keytab:", kmname) : "keytab:", NULL);
        
            ht->hash        = hasher;
      !     ht->emptytable  = emptyhashtable;
            ht->filltable   = NULL;
            ht->addnode     = addhashnode;
            ht->getnode     = gethashnode2;
      ***************
      *** 213,224 ****
            ht->printnode   = NULL;
        
            return ht;
      - }
      - 
      - static void
      - emptykeytab(HashTable ht)
      - {
      -     emptyhashtable(ht, INITIAL_KEYTAB);
        }
        
        static Key
      --- 202,207 ----

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMsoJCHD/+HJTpU/hAQGwbwQAmS3UWa7oGsEnAjQark9bChWxqFOdnrGb
9q0GNOIvIrnowyYQ+AupxBXPD1komRyrxtihMgAzcXQ7UeEhqXDZJ4uTmH7clkna
7pVZV5y+tn3pEJ/mHKHh2WYBb69h7UjIEssgecHYY0WEnTOFe+2oQUv2FnCMsGwN
EqeIn7z+v4E=
=qXA6
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author