mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 13:29:06 +08:00
Merge pull request #238 from nagamalli9999/master
linkhash.c: optimised the table_free path
This commit is contained in:
@@ -562,10 +562,9 @@ int lh_table_resize(struct lh_table *t, int new_size)
|
|||||||
void lh_table_free(struct lh_table *t)
|
void lh_table_free(struct lh_table *t)
|
||||||
{
|
{
|
||||||
struct lh_entry *c;
|
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);
|
t->free_fn(c);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(t->table);
|
free(t->table);
|
||||||
free(t);
|
free(t);
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ extern struct lh_table* lh_table_new(int size,
|
|||||||
* Convenience function to create a new linkhash
|
* Convenience function to create a new linkhash
|
||||||
* table with char keys.
|
* table with char keys.
|
||||||
* @param size initial table size.
|
* @param size initial table size.
|
||||||
* @param name table name.
|
|
||||||
* @param free_fn callback function used to free memory for entries.
|
* @param free_fn callback function used to free memory for entries.
|
||||||
* @return On success, a pointer to the new linkhash table is returned.
|
* @return On success, a pointer to the new linkhash table is returned.
|
||||||
* On error, a null pointer 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
|
* Convenience function to create a new linkhash
|
||||||
* table with ptr keys.
|
* table with ptr keys.
|
||||||
* @param size initial table size.
|
* @param size initial table size.
|
||||||
* @param name table name.
|
|
||||||
* @param free_fn callback function used to free memory for entries.
|
* @param free_fn callback function used to free memory for entries.
|
||||||
* @return On success, a pointer to the new linkhash table is returned.
|
* @return On success, a pointer to the new linkhash table is returned.
|
||||||
* On error, a null pointer is returned.
|
* On error, a null pointer is returned.
|
||||||
|
|||||||
Reference in New Issue
Block a user