From 36cdf163dfbcac5b0e7fedbd55c817b5d5c971fb Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Sun, 24 Sep 2023 09:07:34 -0400 Subject: [PATCH] Add hash_st_free --- hash.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hash.c b/hash.c index dd6429b6c0..8e0295c38e 100644 --- a/hash.c +++ b/hash.c @@ -1160,7 +1160,7 @@ ar_clear(VALUE hash) } static void -hash_st_free_and_clear_table(VALUE hash) +hash_st_free(VALUE hash) { HASH_ASSERT(RHASH_ST_TABLE_P(hash)); @@ -1168,6 +1168,12 @@ hash_st_free_and_clear_table(VALUE hash) free(tab->bins); free(tab->entries); +} + +static void +hash_st_free_and_clear_table(VALUE hash) +{ + hash_st_free(hash); RHASH_ST_CLEAR(hash); } @@ -1974,7 +1980,7 @@ rb_hash_rehash(VALUE hash) rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp); - hash_st_free_and_clear_table(hash); + hash_st_free(hash); RHASH_ST_TABLE_SET(hash, tbl); RHASH_ST_CLEAR(tmp); }