Tidy: modernize-use-nullptr
[alexxy/gromacs.git] / src / gromacs / selection / selelem.cpp
index 2c81620370e427ae2ddb8fdd780b32dcd51b70a4..43553d4bc9653e09aae8eb22c17f0844b8e8883e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -69,7 +69,7 @@
 const char *
 _gmx_selelem_type_str(const gmx::SelectionTreeElement &sel)
 {
-    const char *p = NULL;
+    const char *p = nullptr;
     switch (sel.type)
     {
         case SEL_CONST:      p = "CONST";    break;
@@ -97,7 +97,7 @@ _gmx_selelem_type_str(const gmx::SelectionTreeElement &sel)
 const char *
 _gmx_sel_value_type_str(const gmx_ana_selvalue_t *val)
 {
-    const char *p = NULL;
+    const char *p = nullptr;
     switch (val->type)
     {
         case NO_VALUE:       p = "NONE";  break;
@@ -116,7 +116,7 @@ _gmx_sel_value_type_str(const gmx_ana_selvalue_t *val)
 const char *
 _gmx_selelem_boolean_type_str(const gmx::SelectionTreeElement &sel)
 {
-    const char *p = NULL;
+    const char *p = nullptr;
     switch (sel.u.boolt)
     {
         case BOOL_NOT:  p = "NOT"; break;
@@ -151,9 +151,9 @@ SelectionTreeElement::SelectionTreeElement(e_selelem_t              type,
     }
     _gmx_selvalue_clear(&this->v);
     std::memset(&this->u, 0, sizeof(this->u));
-    this->evaluate   = NULL;
-    this->mempool    = NULL;
-    this->cdata      = NULL;
+    this->evaluate   = nullptr;
+    this->mempool    = nullptr;
+    this->cdata      = nullptr;
 }
 
 SelectionTreeElement::~SelectionTreeElement()
@@ -200,7 +200,7 @@ void SelectionTreeElement::freeValues()
         }
     }
     _gmx_selvalue_free(&v);
-    if (type == SEL_SUBEXPRREF && u.param != NULL)
+    if (type == SEL_SUBEXPRREF && u.param != nullptr)
     {
         // TODO: This is now called from two different locations.
         // It is likely that one of them is unnecessary, but that requires
@@ -215,22 +215,22 @@ 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;
+        u.expr.mdata  = nullptr;
+        u.expr.method = nullptr;
         /* Free position data */
         delete u.expr.pos;
-        u.expr.pos = NULL;
+        u.expr.pos = nullptr;
         /* Free position calculation data */
         if (u.expr.pc)
         {
             gmx_ana_poscalc_free(u.expr.pc);
-            u.expr.pc = NULL;
+            u.expr.pc = nullptr;
         }
     }
     if (type == SEL_ARITHMETIC)
     {
         sfree(u.arith.opstr);
-        u.arith.opstr = NULL;
+        u.arith.opstr = nullptr;
     }
     if (type == SEL_SUBEXPR || type == SEL_ROOT
         || (type == SEL_CONST && v.type == GROUP_VALUE))
@@ -281,7 +281,7 @@ void SelectionTreeElement::mempoolRelease()
         case INT_VALUE:
         case REAL_VALUE:
             _gmx_sel_mempool_free(mempool, v.u.ptr);
-            _gmx_selvalue_setstore(&v, NULL);
+            _gmx_selvalue_setstore(&v, nullptr);
             break;
 
         case GROUP_VALUE:
@@ -425,7 +425,7 @@ void SelectionTreeElement::resolveIndexGroupReference(
 {
     GMX_RELEASE_ASSERT(type == SEL_GROUPREF,
                        "Should only be called for index group reference elements");
-    if (grps == NULL)
+    if (grps == nullptr)
     {
         std::string message = formatString(
                     "Cannot match '%s', because index groups are not available.",
@@ -435,7 +435,7 @@ void SelectionTreeElement::resolveIndexGroupReference(
 
     gmx_ana_index_t foundGroup;
     std::string     foundName;
-    if (u.gref.name != NULL)
+    if (u.gref.name != nullptr)
     {
         if (!gmx_ana_indexgrps_find(&foundGroup, &foundName, grps, u.gref.name))
         {
@@ -518,7 +518,7 @@ _gmx_selelem_set_vtype(const gmx::SelectionTreeElementPointer &sel,
 void
 _gmx_selelem_free_param(gmx_ana_selparam_t *param)
 {
-    if (param->val.u.ptr != NULL)
+    if (param->val.u.ptr != nullptr)
     {
         if (param->val.type == GROUP_VALUE)
         {
@@ -534,7 +534,7 @@ _gmx_selelem_free_param(gmx_ana_selparam_t *param)
 void
 _gmx_selelem_free_method(gmx_ana_selmethod_t *method, void *mdata)
 {
-    sel_freefunc free_func = NULL;
+    sel_freefunc free_func = nullptr;
 
     /* Save the pointer to the free function. */
     if (method && method->free)
@@ -670,7 +670,7 @@ _gmx_selelem_print_tree(FILE *fp, const gmx::SelectionTreeElement &sel,
     if ((sel.type == SEL_CONST && sel.v.type == GROUP_VALUE) || sel.type == SEL_ROOT)
     {
         const gmx_ana_index_t *g = sel.v.u.g;
-        if (!g || g->isize == 0 || sel.evaluate != NULL)
+        if (!g || g->isize == 0 || sel.evaluate != nullptr)
         {
             g = &sel.u.cgrp;
         }
@@ -703,10 +703,10 @@ _gmx_selelem_print_tree(FILE *fp, const gmx::SelectionTreeElement &sel,
             fprintf(fp, "\n");
         }
     }
-    else if (sel.type == SEL_SUBEXPRREF && sel.u.param != NULL)
+    else if (sel.type == SEL_SUBEXPRREF && sel.u.param != nullptr)
     {
         fprintf(fp, "%*c param", level*2+1, ' ');
-        if (sel.u.param->name != NULL)
+        if (sel.u.param->name != nullptr)
         {
             fprintf(fp, " \"%s\"", sel.u.param->name);
         }