Gromacs
2022.2
|
#include "gmxpre.h"
#include "selvalue.h"
#include "gromacs/selection/indexutil.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
#include "position.h"
Implements functions in selvalue.h.
Functions | |
void | _gmx_selvalue_clear (gmx_ana_selvalue_t *val) |
Initializes an empty selection value structure. More... | |
void | _gmx_selvalue_free (gmx_ana_selvalue_t *val) |
Frees memory allocated for a selection value structure. More... | |
void | _gmx_selvalue_reserve (gmx_ana_selvalue_t *val, int n) |
Reserve memory for storing selection values. More... | |
void | _gmx_selvalue_getstore_and_release (gmx_ana_selvalue_t *val, void **ptr, int *nalloc) |
Gets and releases the memory pointer for storing selection values. More... | |
void | _gmx_selvalue_setstore (gmx_ana_selvalue_t *val, void *ptr) |
Sets the memory for storing selection values. More... | |
void | _gmx_selvalue_setstore_alloc (gmx_ana_selvalue_t *val, void *ptr, int nalloc) |
Sets the memory for storing selection values and marks it for automatic freeing. More... | |
void _gmx_selvalue_clear | ( | gmx_ana_selvalue_t * | val | ) |
Initializes an empty selection value structure.
[out] | val | Output structure |
The type of val
is not touched. Any contents of val
are discarded without freeing.
void _gmx_selvalue_free | ( | gmx_ana_selvalue_t * | val | ) |
Frees memory allocated for a selection value structure.
[in,out] | val | Values to free. |
The type of val
is not touched. If memory is not allocated, the value pointers are simply cleared without freeing.
void _gmx_selvalue_getstore_and_release | ( | gmx_ana_selvalue_t * | val, |
void ** | ptr, | ||
int * | nalloc | ||
) |
Gets and releases the memory pointer for storing selection values.
[in,out] | val | Value structure to release. |
[out] | ptr | Pointer where the values are stored. |
[out] | nalloc | Pointer where the values are stored. |
Returns the pointer where values of val
were stored in ptr
and nalloc
, and clears the memory in val
.
void _gmx_selvalue_reserve | ( | gmx_ana_selvalue_t * | val, |
int | n | ||
) |
Reserve memory for storing selection values.
[in,out] | val | Value structure to allocate. |
[in] | n | Maximum number of values needed. |
Reserves memory for the values within val
to store at least n
values, of the type specified in the val
structure.
If the type is POS_VALUE or GROUP_VALUE, memory is reserved for the data structures, but no memory is reserved inside these newly allocated data structures. Similarly, for STR_VALUE values, the pointers are set to NULL. For other values, the memory is uninitialized.
void _gmx_selvalue_setstore | ( | gmx_ana_selvalue_t * | val, |
void * | ptr | ||
) |
Sets the memory for storing selection values.
[in,out] | val | Value structure to set storage for. |
[in] | ptr | Pointer where the values should be stored. |
Automatic memory management is disabled for ptr
. Asserts if val
had a previous storage that it owned, as that would result in a memory leak.
void _gmx_selvalue_setstore_alloc | ( | gmx_ana_selvalue_t * | val, |
void * | ptr, | ||
int | nalloc | ||
) |
Sets the memory for storing selection values and marks it for automatic freeing.
[in,out] | val | Value structure to set storage for. |
[in] | ptr | Pointer where the values should be stored. |
[in] | nalloc | Number of values allocated for ptr . |
Asserts if val
had a previous storage that it owned, as that would result in a memory leak.