[GRASS-SVN] r42504 - grass-addons/raster/r.stream.basins

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jun 8 03:34:50 EDT 2010


Author: mmetz
Date: 2010-06-08 03:34:36 -0400 (Tue, 08 Jun 2010)
New Revision: 42504

Modified:
   grass-addons/raster/r.stream.basins/catchment.c
Log:
fix for fifo error message

Modified: grass-addons/raster/r.stream.basins/catchment.c
===================================================================
--- grass-addons/raster/r.stream.basins/catchment.c	2010-06-07 23:13:54 UTC (rev 42503)
+++ grass-addons/raster/r.stream.basins/catchment.c	2010-06-08 07:34:36 UTC (rev 42504)
@@ -1,6 +1,6 @@
 #include "global.h"
 
-int tail, head, has_point;
+static int tail, head, has_point;
 
 /* 
    Link: a channel between junction
@@ -178,15 +178,16 @@
 /* fifo functions */
 int fifo_insert(POINT point)
 {
+    if (tail > fifo_max) {
+	G_debug(1, "tail > fifo_max");
+	tail = 0;
+    }
     if (has_point && tail == head + 1)
 	G_fatal_error("fifo queue: circular buffer too small");
-	
+
+    /* allow tail to become fifomax + 1 */
     fifo_outlet[tail++] = point;
     has_point = 1;
-    if (tail > fifo_max) {
-	G_debug(1, "tail > fifo_max");
-	tail = 0;
-    }
     return 0;
 }
 
@@ -196,7 +197,9 @@
 	G_debug(1, "head >= fifo_max");
 	head = -1;
     }
-    if (++head == tail)
+    /* max value for ++head: fifomax */
+    /* max value for tail: fifomax + 1 */
+    if (++head == tail - 1)
 	has_point = 0;
 	
     return fifo_outlet[head];



More information about the grass-commit mailing list