summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK.Takata <[email protected]>2019-07-30 12:08:33 +0900
committer卜部昌平 <[email protected]>2019-10-21 11:14:36 +0900
commit375124be51c796a53cce9716e83003ef37c7bcf5 ()
tree5203b229f6e5cab7b7dd11ab74121fca8c5853ff
parente70e81b54e10f1882874884564454f566c41b0dd (diff)
st: Do error check only on non-Ruby
Notes: Merged: https://.com/ruby/ruby/pull/2304
-rw-r--r--st.c16
1 files changed, 16 insertions, 0 deletions
@@ -593,9 +593,15 @@ st_init_table_with_size(const struct st_hash_type *type, st_index_t size)
#endif
n = get_power2(size);
tab = (st_table *) malloc(sizeof (st_table));
if (tab == NULL)
return NULL;
tab->type = type;
tab->entry_power = n;
tab->bin_power = features[n].bin_power;
@@ -604,17 +610,21 @@ st_init_table_with_size(const struct st_hash_type *type, st_index_t size)
tab->bins = NULL;
else {
tab->bins = (st_index_t *) malloc(bins_size(tab));
if (tab->bins == NULL) {
free(tab);
return NULL;
}
}
tab->entries = (st_table_entry *) malloc(get_allocated_entries(tab)
* sizeof(st_table_entry));
if (tab->entries == NULL) {
st_free_table(tab);
return NULL;
}
#ifdef ST_DEBUG
memset(tab->entries, ST_INIT_VAL_BYTE,
get_allocated_entries(tab) * sizeof(st_table_entry));
@@ -1312,24 +1322,30 @@ st_copy(st_table *old_tab)
st_table *new_tab;
new_tab = (st_table *) malloc(sizeof(st_table));
if (new_tab == NULL)
return NULL;
*new_tab = *old_tab;
if (old_tab->bins == NULL)
new_tab->bins = NULL;
else {
new_tab->bins = (st_index_t *) malloc(bins_size(old_tab));
if (new_tab->bins == NULL) {
free(new_tab);
return NULL;
}
}
new_tab->entries = (st_table_entry *) malloc(get_allocated_entries(old_tab)
* sizeof(st_table_entry));
if (new_tab->entries == NULL) {
st_free_table(new_tab);
return NULL;
}
MEMCPY(new_tab->entries, old_tab->entries, st_table_entry,
get_allocated_entries(old_tab));
if (old_tab->bins != NULL)