Beispiel #1
0
/*!
 * \param[in] sel Selection to free.
 *
 * Decrements \ref t_selelem::refcount "sel->refcount" and frees the
 * memory allocated for \p sel and all its children if the reference count
 * reaches zero.
 */
void
_gmx_selelem_free(t_selelem *sel)
{
    /* Decrement the reference counter and do nothing if references remain */
    sel->refcount--;
    if (sel->refcount > 0)
    {
        return;
    }

    /* Free the children.
     * Must be done before freeing other data, because the children may hold
     * references to data in this element. */
    _gmx_selelem_free_chain(sel->child);

    /* Free value storage */
    _gmx_selelem_free_values(sel);

    /* Free other storage */
    _gmx_selelem_free_exprdata(sel);

    /* Free temporary compiler data if present */
    _gmx_selelem_free_compiler_data(sel);

    sfree(sel);
}
Beispiel #2
0
/*!
 * \param[in,out] sc Selection collection to free.
 *
 * The pointer \p sc is invalid after the call.
 */
void
gmx_ana_selcollection_free(gmx_ana_selcollection_t *sc)
{
    int  i;

    sfree(sc->selstr);
    _gmx_selelem_free_chain(sc->root);
    if (sc->sel)
    {
        for (i = 0; i < sc->nr; ++i)
        {
            gmx_ana_selection_free(sc->sel[i]);
        }
    }
    sfree(sc->sel);
    gmx_ana_index_deinit(&sc->gall);
    _gmx_selcollection_clear_symtab(sc);
    sfree(sc);
}
SelectionCollection::Impl::~Impl()
{
    _gmx_selelem_free_chain(_sc.root);
    SelectionList::const_iterator isel;
    for (isel = _sc.sel.begin(); isel != _sc.sel.end(); ++isel)
    {
        delete *isel;
    }
    for (int i = 0; i < _sc.nvars; ++i)
    {
        sfree(_sc.varstrs[i]);
    }
    sfree(_sc.varstrs);
    gmx_ana_index_deinit(&_sc.gall);
    if (_sc.mempool)
    {
        _gmx_sel_mempool_destroy(_sc.mempool);
    }
    if (hasFlag(efOwnPositionCollection))
    {
        gmx_ana_poscalc_coll_free(_sc.pcc);
    }
    clearSymbolTable();
}