Exemple #1
0
void
SelectionTreeElement::freeExpressionData()
{
    if (type == SEL_EXPRESSION || type == SEL_MODIFIER)
    {
        _gmx_selelem_free_method(u.expr.method, u.expr.mdata);
        u.expr.mdata  = NULL;
        u.expr.method = NULL;
        /* Free position data */
        delete u.expr.pos;
        u.expr.pos = NULL;
        /* Free position calculation data */
        if (u.expr.pc)
        {
            gmx_ana_poscalc_free(u.expr.pc);
            u.expr.pc = NULL;
        }
    }
    if (type == SEL_ARITHMETIC)
    {
        sfree(u.arith.opstr);
        u.arith.opstr = NULL;
    }
    if (type == SEL_SUBEXPR || type == SEL_ROOT
            || (type == SEL_CONST && v.type == GROUP_VALUE))
    {
        gmx_ana_index_deinit(&u.cgrp);
    }
    if (type == SEL_GROUPREF)
    {
        sfree(u.gref.name);
    }
}
Exemple #2
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;
    }

    pc->coll->removeCalculation(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);
    }
    delete pc->p;
    if (pc->sbase)
    {
        gmx_ana_poscalc_free(pc->sbase);
        sfree(pc->baseid);
    }
    sfree(pc);
}
Exemple #3
0
/*!
 * \param data Data to free (should point to a \c t_methoddata_pos).
 *
 * Frees the memory allocated for \c t_methoddata_pos::g and
 * \c t_methoddata_pos::pc.
 */
static void
free_data_pos(void *data)
{
    t_methoddata_pos *d = (t_methoddata_pos *)data;

    sfree(d->type);
    gmx_ana_poscalc_free(d->pc);
}
Exemple #4
0
/*!
 * \param[in] pcc   Position calculation collection to free.
 *
 * The pointer \p pcc is invalid after the call.
 * Any calculations in the collection are also freed, no matter how many
 * references to them are left.
 */
void
gmx_ana_poscalc_coll_free(gmx_ana_poscalc_coll_t *pcc)
{
    while (pcc->first)
    {
        gmx_ana_poscalc_free(pcc->first);
    }
    sfree(pcc);
}
Exemple #5
0
PositionCalculationCollection::Impl::~Impl()
{
    // Loop backwards, because there can be internal references in that are
    // correctly handled by this direction.
    while (last_ != NULL)
    {
        GMX_ASSERT(last_->refcount == 1,
                   "Dangling references to position calculations");
        gmx_ana_poscalc_free(last_);
    }
}
Exemple #6
0
/*! \brief
 * Merges two bases into one.
 *
 * \param[in,out] tbase Base calculation to merge to.
 * \param[in]     mbase Base calculation to merge to \p tbase.
 *
 * After the call, \p mbase has been freed and \p tbase is used as the base
 * for all calculations that previously had \p mbase as their base.
 * It is assumed that any overlap between \p tbase and \p mbase is in complete
 * blocks, i.e., that the merge is possible.
 */
static void
merge_bases(gmx_ana_poscalc_t *tbase, gmx_ana_poscalc_t *mbase)
{
    gmx_ana_poscalc_t *pc;

    merge_to_base(tbase, mbase);
    remove_poscalc(mbase);
    /* Set tbase as the base for all calculations that had mbase */
    pc = tbase->coll->first;
    while (pc)
    {
        if (pc->sbase == mbase)
        {
            pc->sbase = tbase;
            tbase->refcount++;
        }
        pc = pc->next;
    }
    /* Free mbase */
    mbase->refcount = 0;
    gmx_ana_poscalc_free(mbase);
}
Exemple #7
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);
    }
}