Пример #1
0
/*-------------------------------------------------------------------------*/
void
clear_struct_type_ref (struct_type_t * pSType)

/* Clear all references held by struct typeobject <pSType>
 */

{
    unsigned short num;

    if (pSType->ref != 0)
    {
        clear_memory_reference(pSType);
        if (pSType->member)
            clear_memory_reference(pSType->member);

        pSType->ref = 0;
        clear_struct_name_ref(pSType->name);
        if (pSType->unique_name)
            pSType->unique_name->info.ref = 0;
        if (pSType->base)
            clear_struct_type_ref(pSType->base);

        for (num = struct_t_size(pSType); num-- > 0; )
        {
            pSType->member[num].name->info.ref = 0;
            clear_lpctype_ref(pSType->member[num].type);
        }
    }

} /* clear_struct_type_ref() */
Пример #2
0
/*-------------------------------------------------------------------------*/
void
clear_lpctype_ref (lpctype_t *t)

/* Clear all references by <t>.
 */

{
    if (!t)
        return;

    if (!t->t_static)
    {
        /* Just in case the allocator forgot something... */
        clear_memory_reference(t);
        t->ref = 0;
    }

    /* Not reference counted pointers become NULL, so they don't
     * become dangling pointers after GC collected their blocks.
     */
    t->array_of = NULL;
    t->unions_of = NULL;

    switch(t->t_class)
    {
    case TCLASS_PRIMARY:
        break; /* Can't happen. See above. */

    case TCLASS_STRUCT:
        if (t->t_struct)
            clear_struct_type_ref(t->t_struct);
        break;

    case TCLASS_ARRAY:
        clear_lpctype_ref(t->t_array.element);
        break;

    case TCLASS_UNION:
        clear_lpctype_ref(t->t_union.head);
        clear_lpctype_ref(t->t_union.member);
        t->t_union.next = NULL;
        break;
    }

} /* clear_lpctype_ref() */