Project

General

Profile

Actions

Feature #6557

closed

Make rb_hash_clear() public

Added by ibc (Iñaki Baz Castillo) almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Assignee:
-
Target version:
[ruby-core:45480]

Description

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

static VALUE
rb_hash_clear(VALUE hash)
{
    rb_hash_modify_check(hash);
    if (!RHASH(hash)->ntbl)
        return hash;
    if (RHASH(hash)->ntbl->num_entries > 0) {
        if (RHASH(hash)->iter_lev > 0)
            rb_hash_foreach(hash, clear_i, 0);
        else
            st_clear(RHASH(hash)->ntbl);
    }

    return hash;
}

Updated by ibc (Iñaki Baz Castillo) almost 12 years ago

The same for rb_hash_size().

Updated by naruse (Yui NARUSE) almost 12 years ago

  • Status changed from Open to Feedback

ibc (Iñaki Baz Castillo) wrote:

Any reason for rb_hash_clear() 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 rb_hash_clear() ?

Updated by ibc (Iñaki Baz Castillo) almost 12 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 rb_ary_clear() 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.

Updated by mame (Yusuke Endoh) over 11 years ago

  • Status changed from Feedback to Closed

Congrats, rb_hash_clear() was public since r37480.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0