Exemplo n.º 1
0
void SelectionTreeElement::mempoolReserve(int count)
{
    if (!mempool)
    {
        return;
    }
    switch (v.type)
    {
    case INT_VALUE:
        v.u.i = static_cast<int *>(
                    _gmx_sel_mempool_alloc(mempool, sizeof(*v.u.i)*count));
        break;

    case REAL_VALUE:
        v.u.r = static_cast<real *>(
                    _gmx_sel_mempool_alloc(mempool, sizeof(*v.u.r)*count));
        break;

    case GROUP_VALUE:
        _gmx_sel_mempool_alloc_group(mempool, v.u.g, count);
        break;

    default:
        GMX_THROW(gmx::InternalError("Memory pooling not implemented for requested type"));
    }
}
Exemplo n.º 2
0
/*!
 * \param[in,out] sel   Selection element to reserve.
 * \param[in]     count Number of values to reserve memory for.
 * \returns       0 on success or if no memory pool, non-zero on error.
 *
 * Reserves memory for the values of \p sel from the \p sel->mempool
 * memory pool. If no memory pool is set, nothing is done.
 */
void
_gmx_selelem_mempool_reserve(t_selelem *sel, int count)
{
    if (!sel->mempool)
    {
        return;
    }
    switch (sel->v.type)
    {
        case INT_VALUE:
            sel->v.u.i = static_cast<int *>(
                    _gmx_sel_mempool_alloc(sel->mempool, sizeof(*sel->v.u.i)*count));
            break;

        case REAL_VALUE:
            sel->v.u.r = static_cast<real *>(
                    _gmx_sel_mempool_alloc(sel->mempool, sizeof(*sel->v.u.r)*count));
            break;

        case GROUP_VALUE:
            _gmx_sel_mempool_alloc_group(sel->mempool, sel->v.u.g, count);
            break;

        default:
            GMX_THROW(gmx::InternalError("Memory pooling not implemented for requested type"));
    }
}
Exemplo n.º 3
0
 void reserve(gmx_ana_index_t *g, int count)
 {
     GMX_RELEASE_ASSERT(g_ == NULL, "Can only reserve one element with one instance");
     _gmx_sel_mempool_alloc_group(mp_, g, count);
     g_ = g;
 }