summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/hash.c
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-12-01 10:29:20 +0000
committerharti <harti@FreeBSD.org>2004-12-01 10:29:20 +0000
commitcf2c3cae344e2c0fd2316b579a8e3698105b58d1 (patch)
treed8d62254033c89332ede3fdf3277528114f7a6b5 /usr.bin/make/hash.c
parenta50f0bcbfd79a523bed7c5e00964a797edad9ff7 (diff)
downloadFreeBSD-src-cf2c3cae344e2c0fd2316b579a8e3698105b58d1.zip
FreeBSD-src-cf2c3cae344e2c0fd2316b579a8e3698105b58d1.tar.gz
Style: remove a lot of unnecessary casts, add some and spell the null
pointer constant as NULL. Checked by: diff -r on the object files before and after
Diffstat (limited to 'usr.bin/make/hash.c')
-rw-r--r--usr.bin/make/hash.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/usr.bin/make/hash.c b/usr.bin/make/hash.c
index f3103dd..0d981c8 100644
--- a/usr.bin/make/hash.c
+++ b/usr.bin/make/hash.c
@@ -105,7 +105,7 @@ Hash_InitTable(Hash_Table *t, int numBuckets)
t->numEntries = 0;
t->size = i;
t->mask = i - 1;
- t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
+ t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
while (--i >= 0)
*hp++ = NULL;
}
@@ -127,7 +127,6 @@ Hash_InitTable(Hash_Table *t, int numBuckets)
*
*---------------------------------------------------------
*/
-
void
Hash_DeleteTable(Hash_Table *t)
{
@@ -137,10 +136,10 @@ Hash_DeleteTable(Hash_Table *t)
for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
for (h = *hp++; h != NULL; h = nexth) {
nexth = h->next;
- free((char *)h);
+ free(h);
}
}
- free((char *)t->bucketPtr);
+ free(t->bucketPtr);
/*
* Set up the hash table to cause memory faults on any future access
@@ -166,7 +165,6 @@ Hash_DeleteTable(Hash_Table *t)
*
*---------------------------------------------------------
*/
-
Hash_Entry *
Hash_FindEntry(Hash_Table *t, char *key)
{
@@ -201,7 +199,6 @@ Hash_FindEntry(Hash_Table *t, char *key)
* Memory may be allocated, and the hash buckets may be modified.
*---------------------------------------------------------
*/
-
Hash_Entry *
Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
{
@@ -234,7 +231,7 @@ Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
*/
if (t->numEntries >= rebuildLimit * t->size)
RebuildTable(t);
- e = (Hash_Entry *)emalloc(sizeof(*e) + keylen);
+ e = emalloc(sizeof(*e) + keylen);
hp = &t->bucketPtr[h & t->mask];
e->next = *hp;
*hp = e;
@@ -264,7 +261,6 @@ Hash_CreateEntry(Hash_Table *t, char *key, Boolean *newPtr)
*
*---------------------------------------------------------
*/
-
void
Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
{
@@ -276,7 +272,7 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
(p = *hp) != NULL; hp = &p->next) {
if (p == e) {
*hp = p->next;
- free((char *)p);
+ free(p);
t->numEntries--;
return;
}
@@ -303,7 +299,6 @@ Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
*
*---------------------------------------------------------
*/
-
Hash_Entry *
Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
{
@@ -331,7 +326,6 @@ Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
*
*---------------------------------------------------------
*/
-
Hash_Entry *
Hash_EnumNext(Hash_Search *searchPtr)
{
@@ -375,7 +369,6 @@ Hash_EnumNext(Hash_Search *searchPtr)
*
*---------------------------------------------------------
*/
-
static void
RebuildTable(Hash_Table *t)
{
@@ -389,7 +382,7 @@ RebuildTable(Hash_Table *t)
i <<= 1;
t->size = i;
t->mask = mask = i - 1;
- t->bucketPtr = hp = (struct Hash_Entry **)emalloc(sizeof(*hp) * i);
+ t->bucketPtr = hp = emalloc(sizeof(*hp) * i);
while (--i >= 0)
*hp++ = NULL;
for (hp = oldhp, i = oldsize; --i >= 0;) {
@@ -400,5 +393,5 @@ RebuildTable(Hash_Table *t)
*xp = e;
}
}
- free((char *)oldhp);
+ free(oldhp);
}
OpenPOWER on IntegriCloud