From 6ced2a50056acbf7caec404a1edfa3b07fa1ac5d Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Wed, 29 Dec 2021 10:48:03 +0100 Subject: feat: remove NULL-checks --- hashtab.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hashtab.c') 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) char * new_key; new_key = strdup(key); // strdup: not standard but commonly used... - new_item = malloc(sizeof(*new_item)); + new_item = malloc(sizeof *new_item); if ( new_key == NULL || new_item == NULL ) { free(new_key); @@ -83,7 +83,7 @@ hash_lookup(struct hash_tab *ht, const char *key, T data, int create) // not found! create? if ( create ) { item = hash_add(ht->table[h], key, data); - if ( item != NULL ) + if ( item ) ht->table[h] = item; else ERROR("can't create item"); @@ -208,7 +208,7 @@ main() while ( getword(stdin, word, sizeof word, first, rest) ) { T *p = hash_lookup(ht, word, 0, 1); - if ( p != NULL ) + if ( p ) ++(*p); } -- cgit v1.3