fixed mismatch in incRefCount/decRefCount calls on objects; some cosmetic changes
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 25 Apr 2017 16:53:10 +0000 (19:53 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 25 Apr 2017 21:16:00 +0000 (00:16 +0300)
src/server/core/datacoll.cpp
src/server/core/layer2.cpp
src/server/core/tools.cpp
src/server/core/tracert.cpp

index 7c62702..fe71158 100644 (file)
@@ -267,7 +267,7 @@ static THREAD_RESULT THREAD_CALL DataCollector(void *pArg)
                                }
                                else
                                {
-               // Change item's status to _T("not supported")
+               // Change item's status to "not supported"
                pItem->setStatus(ITEM_STATUS_NOT_SUPPORTED, true);
                target->decRefCount();
                target = NULL;
index 06e321c..d337255 100644 (file)
@@ -181,9 +181,10 @@ NetObj *FindInterfaceConnectionPoint(const BYTE *macAddr, int *type)
                                     macAddrText, node->getName(), (int)node->getId());
          }
       }
-
-      node->decRefCount();
        }
+
+       for(int i = 0; i < nodes->size(); i++)
+          nodes->get(i)->decRefCount();
        delete nodes;
 
        if ((cp == NULL) && (bestMatchNode != NULL))
index 1dddec5..95de838 100644 (file)
@@ -418,7 +418,7 @@ ObjectArray<ObjectsDistance> *FindNearestObjects(UINT32 currObjectId, int maxDis
    NetObj *currObj = FindObjectById(currObjectId);
    currObj->incRefCount();
    GeoLocation currLocation = currObj->getGeoLocation();
-   if(currLocation.getType() == GL_UNSET)
+   if (currLocation.getType() == GL_UNSET)
    {
       currObj->decRefCount();
       return NULL;
@@ -430,30 +430,29 @@ ObjectArray<ObjectsDistance> *FindNearestObjects(UINT32 currObjectId, int maxDis
        {
           NetObj *object = objects->get(i);
       GeoLocation location = object->getGeoLocation();
-      //leave objects that contain location
-      if(currLocation.getType() == GL_UNSET)
+      if (currLocation.getType() == GL_UNSET)
       {
          object->decRefCount();
          continue;
       }
 
-      //leave object only in given distance
+      // leave object only in given distance
       int distance = currLocation.calculateDistance(location);
-      if(distance > maxDistance)
+      if (distance > maxDistance)
       {
          object->decRefCount();
          continue;
       }
 
-      //remove current object from list
-      if(object->getId() == currObjectId)
+      // remove current object from list
+      if (object->getId() == currObjectId)
       {
          object->decRefCount();
          continue;
       }
 
-      //Filter objects by real path calculation
-      if(calculateRealDistance != NULL)
+      // Filter objects by real path calculation
+      if (calculateRealDistance != NULL)
       {
          distance = calculateRealDistance(location, currLocation);
          if(distance > maxDistance)
@@ -466,7 +465,7 @@ ObjectArray<ObjectsDistance> *FindNearestObjects(UINT32 currObjectId, int maxDis
       result->add(new ObjectsDistance(object, distance));
    }
 
-   //Sort filtered objects
+   // Sort filtered objects
    result->sort(DistanceSortCallback);
 
    currObj->decRefCount();
index c269bd5..99e78de 100644 (file)
@@ -41,7 +41,7 @@ NetworkPath::~NetworkPath()
        for(int i = 0; i < m_hopCount; i++)
                if (m_path[i].object != NULL)
                        m_path[i].object->decRefCount();
-       safe_free(m_path);
+       free(m_path);
 }
 
 /**