hello:
The iftop is very userful while inspecting the flows between hosts. And I
want to add some log features in our environment.
The functions serv_hash_create and ns_hash_create are allocating and
returning a hash:
hash_type* ns_hash_create() {
hash_type* hash_table;
hash_table = xcalloc(hash_table_size, sizeof *hash_table);
hash_table->size = hash_table_size;
hash_table->compare = &ns_hash_compare;
hash_table->hash = &ns_hash_hash;
hash_table->delete_key = &ns_hash_delete_key;
hash_table->copy_key = &ns_hash_copy_key;
hash_initialise(hash_table);
return hash_table;
}
hash_type* serv_hash_create() {
hash_type* hash_table;
hash_table = xcalloc(hash_table_size, sizeof *hash_table);
hash_table->size = hash_table_size;
hash_table->compare = &serv_hash_compare;
hash_table->hash = &serv_hash_hash;
hash_table->delete_key = &serv_hash_delete_key;
hash_table->copy_key = &serv_hash_copy_key;
hash_initialise(hash_table);
return hash_table;
}
Is the clause " hash_table = xcalloc(hash_table_size, sizeof *hash_table);"
a bug?
It allocate a hash_type array with hash_table_size items. Should be "
hash_table = xcalloc(1, sizeof *hash_table);"?
And allocate the hash buckets with " hash_initialise(hash_table);"
Thanks.