symOpen | basic | EMF |
Creates a symbol table for fast indexing
sym_fd_t symOpen(int hash_size);
hash_size | Table size. Nearest prime number is actually used. |
This module implements a highly efficient generic symbol table with update and access routines. Symbols are simple character strings and the values they take can be flexible types as defined by value_t. This module allows multiple symbol tables to be created.
The function allocates a table structure (sym_tabent_t) which consists of the table size, a flag for whether the table is in use, and the actual table itself. The structure is stored in a global sym array that can be accessed by the returned sym_fd_t handle.
Returns an integer (sym_fd_t) to be used as the handle for subsequent calls to the symbol table access functions. Returns -1 on error.
sym_fd_t id; sym_t* sp; id = symOpen(64); ... symEnter(id, "lookup", valueString("value"), 0); ... sp = symLookup(id, "lookup");