Example #1
0
static void
check_svalue(svalue_t *  v)
{
    register int idx;

    nested++;
    if (nested > MAX_RECURSION) {
        return;
    }
    switch (v->type) {
    case T_OBJECT:
        if (v->u.ob->flags & O_DESTRUCTED) {
            free_svalue(v, "reclaim_objects");
            *v = const0u;
            cleaned++;
        }
        break;
    case T_MAPPING:
        gc_mapping(v->u.map);
        break;
    case T_ARRAY:
    case T_CLASS:
        for (idx = 0; idx < v->u.arr->size; idx++)
            check_svalue(&v->u.arr->item[idx]);
        break;
    case T_FUNCTION:
    {
        svalue_t tmp;
        program_t *prog;

        if (v->u.fp->hdr.owner && (v->u.fp->hdr.owner->flags & O_DESTRUCTED)) {
            if (v->u.fp->hdr.type == FP_LOCAL | FP_NOT_BINDABLE) {
                prog = v->u.fp->hdr.owner->prog;
                prog->func_ref--;
                debug(d_flag, ("subtr func ref /%s: now %i\n",
                               prog->name, prog->func_ref));
                if (!prog->ref && !prog->func_ref)
                    deallocate_program(prog);
            }
            free_object(v->u.fp->hdr.owner, "reclaim_objects");
            v->u.fp->hdr.owner = 0;
            cleaned++;
        }

        tmp.type = T_ARRAY;
        if ((tmp.u.arr = v->u.fp->hdr.args))
            check_svalue(&tmp);
        break;
    }
    }
    nested--;
    return;
}
Example #2
0
static void
check_svalue P1(svalue_t *, v)
{
    register int idx;

    nested++;
    if (nested > MAX_RECURSION) {
	return;
    }
    switch (v->type) {
    case T_OBJECT:
	if (v->u.ob->flags & O_DESTRUCTED) {
	    free_svalue(v, "reclaim_objects");
	    *v = const0u;
	    cleaned++;
	}
	break;
    case T_MAPPING:
	gc_mapping(v->u.map);
	break;
    case T_ARRAY:
    case T_CLASS:
	for (idx = 0; idx < v->u.arr->size; idx++)
	    check_svalue(&v->u.arr->item[idx]);
	break;
    case T_FUNCTION:
	{
	    svalue_t tmp;
	    tmp.type = T_ARRAY;
	    if ((tmp.u.arr = v->u.fp->hdr.args))
		check_svalue(&tmp);
	    break;
	}
    }
    nested--;
    return;
}