diff options
-rw-r--r-- | st.c | 34 |
1 files changed, 23 insertions, 11 deletions
@@ -1228,17 +1228,10 @@ st_insert2(st_table *tab, st_data_t key, st_data_t value, return 1; } -/* Create and return a copy of table OLD_TAB. */ st_table * -st_copy(st_table *old_tab) { - st_table *new_tab; - - new_tab = (st_table *) malloc(sizeof(st_table)); -#ifndef RUBY - if (new_tab == NULL) - return NULL; -#endif *new_tab = *old_tab; if (old_tab->bins == NULL) new_tab->bins = NULL; @@ -1246,7 +1239,6 @@ st_copy(st_table *old_tab) new_tab->bins = (st_index_t *) malloc(bins_size(old_tab)); #ifndef RUBY if (new_tab->bins == NULL) { - free(new_tab); return NULL; } #endif @@ -1255,7 +1247,6 @@ st_copy(st_table *old_tab) * sizeof(st_table_entry)); #ifndef RUBY if (new_tab->entries == NULL) { - st_free_table(new_tab); return NULL; } #endif @@ -1263,6 +1254,27 @@ st_copy(st_table *old_tab) get_allocated_entries(old_tab)); if (old_tab->bins != NULL) MEMCPY(new_tab->bins, old_tab->bins, char, bins_size(old_tab)); return new_tab; } |