Feature #6557

Make rb_hash_clear() public

Added by Iñaki Baz Castillo almost 2 years ago. Updated over 1 year ago.

[ruby-core:45480]
Status:Closed
Priority:Normal
Assignee:-
Category:core
Target version:1.9.3

Description

Any reason for rbhashclear() not to be public C API?:

static VALUE
rbhashclear(VALUE hash)
{
rbhashmodifycheck(hash);
if (!RHASH(hash)->ntbl)
return hash;
if (RHASH(hash)->ntbl->num
entries > 0) {
if (RHASH(hash)->iterlev > 0)
rb
hashforeach(hash, cleari, 0);
else
st_clear(RHASH(hash)->ntbl);
}

return hash;

}

History

#1 Updated by Iñaki Baz Castillo almost 2 years ago

The same for rbhashsize().

#2 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Open to Feedback

ibc (Iñaki Baz Castillo) wrote:

Any reason for rbhashclear() not to be public C API?:

Because anyone hadn't request it to be public.
If a function is a public, we can't change the API.
So we don't make it public until anyone request it.

Now you request, could you show the use case of rbhashclear() ?

#3 Updated by Iñaki Baz Castillo almost 2 years ago

Well, I have a C extension (a reactor based on libuv) in which I would like to perform the "loop release" within a single C function (to avoid some steps of the function to be interrupted by an exception or whatever). In such a "release" function I must clear some Ruby arrays and hashes.

Note that rbaryclear() is public.

PS: BTW, I don't receive mails when somebody comments or updates an issue reported by me, is it normal? I use Redmine so I'm sure I've properly configured my account in this Redmine.

Thanks a lot.

#4 Updated by Yusuke Endoh over 1 year ago

  • Status changed from Feedback to Closed

Congrats, rbhashclear() was public since r37480.

Yusuke Endoh mame@tsg.ne.jp

Also available in: Atom PDF