summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-08-25 22:33:07 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-08-25 22:33:07 +0000
commit986ab5e943db7aaed2aed98f8b74e4c26666fdd8 (patch)
tree58cfec1114686823dbdbf22cf2ca52f77eb1075d /hash.c
parent9044dd4d58af4b4d64a6e68b7b76c42d317e7ce5 (diff)
CVS branch clean-up.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/hash.c b/hash.c
index f670eb4a..efd63a6f 100644
--- a/hash.c
+++ b/hash.c
@@ -44,9 +44,11 @@ HASH *hash_create (int nelem)
allow_dup if nonzero, duplicate keys are allowed in the table */
int hash_insert (HASH * table, const char *key, void *data, int allow_dup)
{
- struct hash_elem *ptr = malloc (sizeof (struct hash_elem));
- int h = hash_string ((unsigned char *) key, table->nelem);
+ struct hash_elem *ptr;
+ int h;
+ ptr = (struct hash_elem *) safe_malloc (sizeof (struct hash_elem));
+ h = hash_string ((unsigned char *) key, table->nelem);
ptr->key = key;
ptr->data = data;
@@ -65,7 +67,7 @@ int hash_insert (HASH * table, const char *key, void *data, int allow_dup)
r = strcmp (tmp->key, key);
if (r == 0)
{
- free (ptr);
+ FREE (&ptr);
return (-1);
}
if (r > 0)
@@ -109,9 +111,7 @@ void hash_delete_hash (HASH * table, int hash, const char *key, const void *data
table->table[hash] = ptr->next;
if (destroy)
destroy (ptr->data);
- memset (ptr, 0, sizeof (struct hash_elem));
- free (ptr);
- ptr = 0;
+ FREE (&ptr);
return;
}
}