From 5fb63a09f9bda16d244c298078ce868e7ce587d2 Mon Sep 17 00:00:00 2001 From: Eswar Yaganti Date: Sat, 25 Jun 2016 22:50:36 +0530 Subject: [PATCH 1/2] linkhash.c: optimised the table_free path --- linkhash.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linkhash.c b/linkhash.c index 64074ac..6874273 100644 --- a/linkhash.c +++ b/linkhash.c @@ -562,10 +562,9 @@ int lh_table_resize(struct lh_table *t, int new_size) void lh_table_free(struct lh_table *t) { struct lh_entry *c; - for(c = t->head; c != NULL; c = c->next) { - if(t->free_fn) { + if(t->free_fn) { + for(c = t->head; c != NULL; c = c->next) t->free_fn(c); - } } free(t->table); free(t); From 78cf6e63ff2ea1b4fa32ee6632cd87d74a0eb616 Mon Sep 17 00:00:00 2001 From: Eswar Yaganti Date: Sat, 25 Jun 2016 23:05:41 +0530 Subject: [PATCH 2/2] linkhash.h: removed redundant params from comments --- linkhash.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/linkhash.h b/linkhash.h index 8be625a..b9e114b 100644 --- a/linkhash.h +++ b/linkhash.h @@ -175,7 +175,6 @@ extern struct lh_table* lh_table_new(int size, * Convenience function to create a new linkhash * table with char keys. * @param size initial table size. - * @param name table name. * @param free_fn callback function used to free memory for entries. * @return On success, a pointer to the new linkhash table is returned. * On error, a null pointer is returned. @@ -188,7 +187,6 @@ extern struct lh_table* lh_kchar_table_new(int size, * Convenience function to create a new linkhash * table with ptr keys. * @param size initial table size. - * @param name table name. * @param free_fn callback function used to free memory for entries. * @return On success, a pointer to the new linkhash table is returned. * On error, a null pointer is returned.