summaryrefslogtreecommitdiff
path: root/source3/lib/hash.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-09-17 02:19:44 +0000
committerSimo Sorce <idra@samba.org>2001-09-17 02:19:44 +0000
commit484a7c0341fe033fe26fe1e6b597ed1c456c39d4 (patch)
treec2f2344c757fffba5b6cc190e6ed13ef64b89266 /source3/lib/hash.c
parent31c3f7a8b2ff62d4cfc1ed9d831b95eba0da525f (diff)
downloadsamba-484a7c0341fe033fe26fe1e6b597ed1c456c39d4.tar.gz
samba-484a7c0341fe033fe26fe1e6b597ed1c456c39d4.tar.bz2
samba-484a7c0341fe033fe26fe1e6b597ed1c456c39d4.zip
move to SAFE_FREE()
(This used to be commit 60e907b7e8e1c008463a88ed2b076344278986ef)
Diffstat (limited to 'source3/lib/hash.c')
-rw-r--r--source3/lib/hash.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/source3/lib/hash.c b/source3/lib/hash.c
index 92840a4c98..6c81931152 100644
--- a/source3/lib/hash.c
+++ b/source3/lib/hash.c
@@ -192,8 +192,8 @@ hash_element *hash_insert(hash_table *table, char *value, char *key)
bucket = hash_elem->bucket;
ubi_dlRemThis(&(table->lru_chain), &(hash_elem->lru_link.lru_link));
ubi_dlRemThis(bucket, (ubi_dlNodePtr)hash_elem);
- free((char*)(hash_elem->value));
- free(hash_elem);
+ SAFE_FREE((char*)(hash_elem->value));
+ SAFE_FREE(hash_elem);
} else {
table->num_elements += 1;
}
@@ -238,10 +238,8 @@ void hash_remove(hash_table *table, hash_element *hash_elem)
if (hash_elem) {
ubi_dlRemove(&(table->lru_chain), &(hash_elem->lru_link.lru_link));
ubi_dlRemove(hash_elem->bucket, (ubi_dlNodePtr) hash_elem);
- if(hash_elem->value)
- free((char *)(hash_elem->value));
- if(hash_elem)
- free((char *) hash_elem);
+ SAFE_FREE(hash_elem->value);
+ SAFE_FREE(hash_elem);
table->num_elements--;
}
}
@@ -285,8 +283,7 @@ static BOOL enlarge_hash_table(hash_table *table)
table->num_elements++;
}
}
- if(buckets)
- free((char *) buckets);
+ SAFE_FREE(buckets);
return True;
}
@@ -309,14 +306,11 @@ void hash_clear(hash_table *table)
for (i = 0; i < table->size; bucket++, i++) {
while (bucket->count != 0) {
hash_elem = (hash_element *) ubi_dlRemHead(bucket);
- if(hash_elem->value)
- free((char *)(hash_elem->value));
- if(hash_elem)
- free((char *)hash_elem);
+ SAFE_FREE(hash_elem->value);
+ SAFE_FREE(hash_elem);
}
}
table->size = 0;
- if(table->buckets)
- free((char *) table->buckets);
+ SAFE_FREE(table->buckets);
table->buckets = NULL;
}