Creating and Freeing a Hash Table




Creating and Freeing a Hash Table - Untitled















Next: Looking Up or Entering a String,
Previous: Hash Tables,
Up: Hash Tables



2.18.1 Creating and freeing a hash table

To create a hash table, create an instance of a struct
bfd_hash_table (defined in bfd.h) and call
bfd_hash_table_init (if you know approximately how many
entries you will need, the function bfd_hash_table_init_n,
which takes a size argument, may be used).
bfd_hash_table_init returns FALSE if some sort of
error occurs.

The function bfd_hash_table_init take as an argument a
function to use to create new entries. For a basic hash
table, use the function bfd_hash_newfunc. See Deriving a New Hash Table Type, for why you would want to use a
different value for this argument.

bfd_hash_table_init will create an objalloc which will be
used to allocate new entries. You may allocate memory on this
objalloc using bfd_hash_allocate.

Use bfd_hash_table_free to free up all the memory that has
been allocated for a hash table. This will not free up the
struct bfd_hash_table itself, which you must provide.

Use bfd_hash_set_default_size to set the default size of
hash table to use.





Wyszukiwarka

Podobne podstrony:
Creating a Linker Hash Table
SHSpec 033 6108C03 Creation and Goals
Traversing a Hash Table
Creating and Publishing a WordPress Blog
2001 02 Bootdisk Creating and Using Emergency Recovery Disks
Deriving a New Hash Table Type
Adding Symbols to the Hash Table
2002 09 Creating Virtual Worlds with Pov Ray and the Right Front End
Scott Guinn Table Hopping Cups And Balls
CWIHP Bulletin nr 11 Editor s note and table of contests
Foreword and Table of Contents
CWIHP Bulletin nr 14 15 Introduction and table of contests

więcej podobnych podstron