Configuration/allocate_keywords_hash_table [ Functions ]

FUNCTION

Allocates space for the keyword hash table.

The size of the table depends on the number of keywords rounded up to the next power of two.

SYNOPSIS

void allocate_keywords_hash_table(
    void )

SOURCE

{
    unsigned int        i;

    // Calculate hash table size (powers of two)
    for ( keywords_hash_mask = 2;
          keywords_hash_mask < configuration.keywords.number;
          keywords_hash_mask <<= 1 );
    keywords_hash_mask -= 1;

    // Allocate space for hash table
    keywords_hash = RB_malloc( ( keywords_hash_mask + 1 ) *
                               sizeof( struct keywords_hash_s * ) );

    // Zero out all rows
    for ( i = 0; i <= keywords_hash_mask; i++ )
    {
        keywords_hash[i] = NULL;
    }
}