示例#1
0
/*!
 * \param  pc  Position calculation data to be freed.
 *
 * The \p pc pointer is invalid after the call.
 */
void
gmx_ana_poscalc_free(gmx_ana_poscalc_t *pc)
{
    if (!pc)
    {
        return;
    }

    pc->refcount--;
    if (pc->refcount > 0)
    {
        return;
    }

    remove_poscalc(pc);
    if (pc->b.nalloc_index > 0)
    {
        sfree(pc->b.index);
    }
    if (pc->b.nalloc_a > 0)
    {
        sfree(pc->b.a);
    }
    if (pc->flags & POS_COMPLWHOLE)
    {
        gmx_ana_index_deinit(&pc->gmax);
    }
    if (pc->p)
    {
        gmx_ana_pos_free(pc->p);
    }
    if (pc->sbase)
    {
        gmx_ana_poscalc_free(pc->sbase);
        sfree(pc->baseid);
    }
    sfree(pc);
}
示例#2
0
/*!
 * \param[in] sel Selection to free.
 */
void
_gmx_selelem_free_exprdata(t_selelem *sel)
{
    if (sel->type == SEL_EXPRESSION || sel->type == SEL_MODIFIER)
    {
        _gmx_selelem_free_method(sel->u.expr.method, sel->u.expr.mdata);
        sel->u.expr.mdata = NULL;
        sel->u.expr.method = NULL;
        /* Free position data */
        if (sel->u.expr.pos)
        {
            gmx_ana_pos_free(sel->u.expr.pos);
            sel->u.expr.pos = NULL;
        }
        /* Free position calculation data */
        if (sel->u.expr.pc)
        {
            gmx_ana_poscalc_free(sel->u.expr.pc);
            sel->u.expr.pc = NULL;
        }
    }
    if (sel->type == SEL_ARITHMETIC)
    {
        sfree(sel->u.arith.opstr);
        sel->u.arith.opstr = NULL;
    }
    if (sel->type == SEL_SUBEXPR || sel->type == SEL_ROOT
        || (sel->type == SEL_CONST && sel->v.type == GROUP_VALUE))
    {
        gmx_ana_index_deinit(&sel->u.cgrp);
    }
    if (sel->type == SEL_GROUPREF)
    {
        sfree(sel->u.gref.name);
    }
}