/*! * \param[in] type Type of selection element to allocate. * \returns Pointer to the newly allocated and initialized element. * * \c t_selelem::type is set to \p type, * \c t_selelem::v::type is set to \ref GROUP_VALUE for boolean and comparison * expressions and \ref NO_VALUE for others, * \ref SEL_ALLOCVAL is set for non-root elements (\ref SEL_ALLOCDATA is also * set for \ref SEL_BOOLEAN elements), * and \c t_selelem::refcount is set to one. * All the pointers are set to NULL. */ t_selelem * _gmx_selelem_create(e_selelem_t type) { t_selelem *sel; snew(sel, 1); sel->name = NULL; sel->type = type; sel->flags = (type != SEL_ROOT) ? SEL_ALLOCVAL : 0; if (type == SEL_BOOLEAN) { sel->v.type = GROUP_VALUE; sel->flags |= SEL_ALLOCDATA; } else { sel->v.type = NO_VALUE; } _gmx_selvalue_clear(&sel->v); sel->evaluate = NULL; sel->mempool = NULL; sel->child = NULL; sel->next = NULL; sel->refcount = 1; return sel; }
SelectionTreeElement::SelectionTreeElement(e_selelem_t type, const SelectionLocation &location) : location_(location) { this->type = type; this->flags = (type != SEL_ROOT) ? SEL_ALLOCVAL : 0; if (type == SEL_BOOLEAN) { this->v.type = GROUP_VALUE; this->flags |= SEL_ALLOCDATA; } else { this->v.type = NO_VALUE; } _gmx_selvalue_clear(&this->v); std::memset(&this->u, 0, sizeof(this->u)); this->evaluate = NULL; this->mempool = NULL; this->cdata = NULL; }