method

finalize

Importance_0
v2_4_6 - Show latest stable - 0 notes - Class: WeakMap
finalize(p1) private

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
static VALUE
wmap_finalize(VALUE self, VALUE objid)
{
    st_data_t orig, wmap, data;
    VALUE obj, *rids, i, size;
    struct weakmap *w;

    TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
    /* Get reference from object id. */
    obj = obj_id_to_ref(objid);

    /* obj is original referenced object and/or weak reference. */
    orig = (st_data_t)obj;
    if (st_delete(w->obj2wmap, &orig, &data)) {
        rids = (VALUE *)data;
        size = *rids++;
        for (i = 0; i < size; ++i) {
            wmap = (st_data_t)rids[i];
            st_delete(w->wmap2obj, &wmap, NULL);
        }
        ruby_sized_xfree((VALUE *)data, (size + 1) * sizeof(VALUE));
    }

    wmap = (st_data_t)obj;
    if (st_delete(w->wmap2obj, &wmap, &orig)) {
        wmap = (st_data_t)obj;
        st_update(w->obj2wmap, orig, wmap_final_func, wmap);
    }
    return self;
}
Register or log in to add new notes.