HashInit and HashEmpty should exist

Issue #25 resolved
Justin Schwartz created an issue

LinkedLists have the functions LLInit, LLEmpty, LLAlloc, and LLFree. LLAlloc calls LLInit, and LLFree calls LLEmpty.

HashTables only have HashAlloc and HashFree, the initialization/cleanup takes place in those functions. The model should be changed to have those functions act like LLInit/LLFree, and call separate functions called HashInit and HashEmpty.

Ultimately this will eliminate the requirement that all HashTables must be dynamically allocated.

Comments (5)

  1. Justin Schwartz reporter

    HashEmpty would be confusing, apparently, so the function should be called HashDeinit instead. Someone wanting to empty a HashTable then continue to use it would either call HashDeinit followed by another HashInit, or HashEnum passed hash_enum_afree, as before. HashDeinit frees all internal data and leaves the table unusable until initialized again.

  2. Log in to comment