Fixed bug in hash.c

A bug in the delete function in hash.c was preventing the unit test of the new set ID API functions from running properly. In fixing this bug the entire hash table code was refactored to make it look more like the mempool service routines. Also the need to copy the string passed into the table's insert function was eliminated.
This commit is contained in:
Lew Rossman
2018-10-18 10:03:09 -04:00
parent b3e84e0c42
commit 60a79de4a9
7 changed files with 212 additions and 222 deletions

View File

@@ -7,24 +7,16 @@
#ifndef HASH_H
#define HASH_H
#define ENHASHTABLEMAXSIZE 128000
#define NOTFOUND 0
typedef struct HTentryStruct
{
char *key;
int data;
struct HTentryStruct *next;
} ENHashEntry;
typedef struct DataEntryStruct *HashTable;
typedef ENHashEntry *ENHashTable;
HashTable *hashtable_create(void);
int hashtable_insert(HashTable *, char *, int);
int hashtable_find(HashTable *, char *);
char *hashtable_findkey(HashTable *, char *);
void hashtable_free(HashTable *);
int hashtable_update(HashTable *ht, char *key, int new_data);
int hashtable_delete(HashTable *ht, char *key);
ENHashTable *ENHashTableCreate(void);
int ENHashTableInsert(ENHashTable *, char *, int);
int ENHashTableFind(ENHashTable *, char *);
char *ENHashTableFindKey(ENHashTable *, char *);
void ENHashTableFree(ENHashTable *);
int ENHashTableUpdate(ENHashTable *ht, char *key, int new_data);
int ENHashTableDelete(ENHashTable *ht, char *key);
#endif