Beispiel #1
0
static void
vec_rebuild_lookup_table(struct plot *pl)
{
    int cnt;                            /* count entries */
    struct dvec *d;                     /* dynamic vector */
    NGHASHPTR lookup_p;                 /* lookup table for speed */
    SPICE_DSTRING dbuf;                 /* dynamic buffer */
    char *lower_name;                   /* lower case name */

    if (pl->pl_lookup_table) {
        nghash_empty(pl->pl_lookup_table, NULL, NULL);
    } else {
        cnt = 0;
        for (d = pl->pl_dvecs; d; d = d->v_next)
            cnt++;
        pl->pl_lookup_table = nghash_init(cnt);
        /* allow multiple entries */
        nghash_unique(pl->pl_lookup_table, FALSE);
    }
    lookup_p = pl->pl_lookup_table;
    spice_dstring_init(&dbuf);
    for (d = pl->pl_dvecs; d; d = d->v_next) {
        spice_dstring_reinit(&dbuf);
        lower_name = spice_dstring_append_lower(&dbuf, d->v_name, -1);
        nghash_insert(lookup_p, lower_name, d);
    }
    spice_dstring_free(&dbuf);
    pl->pl_lookup_valid = TRUE;
}
Beispiel #2
0
void nghash_free_string_hashtable(NGHASHPTR hashtable)
{
    hashtable->call_from_free = TRUE;
    nghash_empty(hashtable, (ngdelete) nghash_free_string_func, NULL ) ;
    hashtable->call_from_free = FALSE ;
    NGFREE( hashtable->hash_table ) ;
    NGFREE( hashtable ) ;
} /* end nghash_free_string_hashtable() */
Beispiel #3
0
void nghash_free(NGHASHPTR hashtable, void (*delete_data) (void *),
                 void (*delete_key) (void *))
{
    hashtable->call_from_free = TRUE;
    nghash_empty(hashtable, delete_data, delete_key ) ;
    hashtable->call_from_free = FALSE ;
    NGFREE( hashtable->hash_table ) ;
    NGFREE( hashtable ) ;
} /* end nghash_free() */