aboutsummaryrefslogtreecommitdiff
path: root/hashtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'hashtab.c')
-rw-r--r--hashtab.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/hashtab.c b/hashtab.c
index 9f4e4a8..256fac9 100644
--- a/hashtab.c
+++ b/hashtab.c
@@ -51,7 +51,7 @@ hash_add(struct hash_item *next, const char *key, T data)
51 char * new_key; 51 char * new_key;
52 52
53 new_key = strdup(key); // strdup: not standard but commonly used... 53 new_key = strdup(key); // strdup: not standard but commonly used...
54 new_item = malloc(sizeof(*new_item)); 54 new_item = malloc(sizeof *new_item);
55 55
56 if ( new_key == NULL || new_item == NULL ) { 56 if ( new_key == NULL || new_item == NULL ) {
57 free(new_key); 57 free(new_key);
@@ -83,7 +83,7 @@ hash_lookup(struct hash_tab *ht, const char *key, T data, int create)
83 // not found! create? 83 // not found! create?
84 if ( create ) { 84 if ( create ) {
85 item = hash_add(ht->table[h], key, data); 85 item = hash_add(ht->table[h], key, data);
86 if ( item != NULL ) 86 if ( item )
87 ht->table[h] = item; 87 ht->table[h] = item;
88 else 88 else
89 ERROR("can't create item"); 89 ERROR("can't create item");
@@ -208,7 +208,7 @@ main()
208 208
209 while ( getword(stdin, word, sizeof word, first, rest) ) { 209 while ( getword(stdin, word, sizeof word, first, rest) ) {
210 T *p = hash_lookup(ht, word, 0, 1); 210 T *p = hash_lookup(ht, word, 0, 1);
211 if ( p != NULL ) 211 if ( p )
212 ++(*p); 212 ++(*p);
213 } 213 }
214 214