parse/htab.c
/* Resizes the hash table by copying all
 * the old keys into the right slots in a
 * new table. */
Resizes the hash table by copying all
the old keys into the right slots in a
new table.
Resizes the hash table by copying all the old keys into the right slots in a new table .
static void grow(Htab *ht, int sz)
{
    void **oldk;
    void **oldv;
    ulong *oldh;
    char *oldd;
    int oldsz;
    int i;
    oldk = ht->keys;
    oldv = ht->vals;
    oldh = ht->hashes;
    oldd = ht->dead;
    oldsz = ht->sz;
    ht->nelt = 0;
    ht->ndead = 0;
    ht->sz = sz;
    ht->keys = zalloc(sz*sizeof(void*));
    ht->vals = zalloc(sz*sizeof(void*));
    ht->hashes = zalloc(sz*sizeof(void*));
    ht->dead = zalloc(sz*sizeof(void*));
    for (i = 0; i < oldsz; i++)
        if (oldh[i] && !oldd[i])
            htput(ht, oldk[i], oldv[i]);
    free(oldh);
    free(oldk);
    free(oldv);
    free(oldd);
}
static void grow ( Htab * ht , int sz ) { void * * oldk ; void * * oldv ; ulong * oldh ; char * oldd ; int oldsz ; int i ; oldk = ht -> keys ; oldv = ht -> vals ; oldh = ht -> hashes ; oldd = ht -> dead ; oldsz = ht -> sz ; ht -> nelt = 0 ; ht -> ndead = 0 ; ht -> sz = sz ; ht -> keys = zalloc ( sz * sizeof ( void * ) ) ; ht -> vals = zalloc ( sz * sizeof ( void * ) ) ; ht -> hashes = zalloc ( sz * sizeof ( void * ) ) ; ht -> dead = zalloc ( sz * sizeof ( void * ) ) ; for ( i = 0 ; i < oldsz ; i ++ ) if ( oldh [ i ] && ! oldd [ i ] ) htput ( ht , oldk [ i ] , oldv [ i ] ) ; free ( oldh ) ; free ( oldk ) ; free ( oldv ) ; free ( oldd ) ; }
Resizes the hash table by copying all
 the old keys into the right slots in a
 new table.
Resizes the hash table by copying all the old keys into the right slots in a new table .