Forráskód Böngészése

ticket https://trac.osgeo.org/grass/ticket/224: BUG1 fixed in trunk

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36109 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 16 éve
szülő
commit
7ae0054537
2 módosított fájl, 16 hozzáadás és 4 törlés
  1. 5 4
      lib/vector/dglib/heap.c
  2. 11 0
      lib/vector/dglib/sp-template.c

+ 5 - 4
lib/vector/dglib/heap.c

@@ -64,6 +64,7 @@ int dglHeapInsertMin(dglHeap_s * pheap,
 
     i = ++pheap->index;
 
+
     while (i != 1 && key < pheap->pnode[i / 2].key) {
 	pheap->pnode[i] = pheap->pnode[i / 2];
 	i /= 2;
@@ -86,7 +87,7 @@ int dglHeapExtractMin(dglHeap_s * pheap, dglHeapNode_s * pnoderet)
 
     *pnoderet = pheap->pnode[1];
 
-    temp = pheap->pnode[pheap->index--];
+    temp = pheap->pnode[pheap->index--]; /* keep last item */
 
     iparent = 1;
     ichild = 2;
@@ -97,13 +98,13 @@ int dglHeapExtractMin(dglHeap_s * pheap, dglHeapNode_s * pnoderet)
 	    ichild++;
 	}
 	if (temp.key <= pheap->pnode[ichild].key)
-	    break;
+	    break;    /* are you sure ? */
 
 	pheap->pnode[iparent] = pheap->pnode[ichild];
 	iparent = ichild;
 	ichild *= 2;
     }
-    pheap->pnode[iparent] = temp;
+    pheap->pnode[iparent] = temp; /* reinsert last item */
 
     return 1;
 }
@@ -156,7 +157,7 @@ int dglHeapExtractMax(dglHeap_s * pheap, dglHeapNode_s * pnoderet)
 	    ichild++;
 	}
 	if (temp.key >= pheap->pnode[ichild].key)
-	    break;
+	    break;     /* are you sure ? */
 
 	pheap->pnode[iparent] = pheap->pnode[ichild];
 	iparent = ichild;

+ 11 - 0
lib/vector/dglib/sp-template.c

@@ -368,6 +368,17 @@ int DGL_SP_DIJKSTRA_FUNC(dglGraph_s * pgraph,
 	else if (pgraph->iErrno != DGL_ERR_TailNodeNotFound) {
 	    goto sp_error;
 	}
+	/*
+	 * reset visited status for existing cache: fix for BUG1
+	 */
+	if (pCache->pvVisited) {
+	    avl_destroy(pCache->pvVisited, dglTreeTouchI32Cancel);
+
+	    if ((pCache->pvVisited =
+		avl_create(dglTreeTouchI32Compare, NULL,
+			dglTreeGetAllocator())) == NULL)
+		return -1;
+	}
     }
 
     /*