[GRASS-SVN] r36109 - grass/trunk/lib/vector/dglib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 26 10:57:40 EST 2009
Author: mmetz
Date: 2009-02-26 10:57:39 -0500 (Thu, 26 Feb 2009)
New Revision: 36109
Modified:
grass/trunk/lib/vector/dglib/heap.c
grass/trunk/lib/vector/dglib/sp-template.c
Log:
ticket #224: BUG1 fixed in trunk
Modified: grass/trunk/lib/vector/dglib/heap.c
===================================================================
--- grass/trunk/lib/vector/dglib/heap.c 2009-02-26 15:14:52 UTC (rev 36108)
+++ grass/trunk/lib/vector/dglib/heap.c 2009-02-26 15:57:39 UTC (rev 36109)
@@ -64,6 +64,7 @@
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 @@
*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 @@
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 @@
ichild++;
}
if (temp.key >= pheap->pnode[ichild].key)
- break;
+ break; /* are you sure ? */
pheap->pnode[iparent] = pheap->pnode[ichild];
iparent = ichild;
Modified: grass/trunk/lib/vector/dglib/sp-template.c
===================================================================
--- grass/trunk/lib/vector/dglib/sp-template.c 2009-02-26 15:14:52 UTC (rev 36108)
+++ grass/trunk/lib/vector/dglib/sp-template.c 2009-02-26 15:57:39 UTC (rev 36109)
@@ -368,6 +368,17 @@
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;
+ }
}
/*
More information about the grass-commit
mailing list