[GRASS-SVN] r70706 - grass/trunk/vector/v.to.db

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 1 03:08:54 PST 2017


Author: hcho
Date: 2017-03-01 03:08:54 -0800 (Wed, 01 Mar 2017)
New Revision: 70706

Modified:
   grass/trunk/vector/v.to.db/main.c
Log:
v.to.db: Fix r70633; Don't throw a fatal error when there are no features

Modified: grass/trunk/vector/v.to.db/main.c
===================================================================
--- grass/trunk/vector/v.to.db/main.c	2017-03-01 08:43:48 UTC (rev 70705)
+++ grass/trunk/vector/v.to.db/main.c	2017-03-01 11:08:54 UTC (rev 70706)
@@ -68,10 +68,10 @@
     }
 
     /* allocate array for values */
-    /* (+ 1 is for cat -1 (no category) reported at the end ) */
+    /* (+1 is for cat -1 (no category) reported at the end ) */
     findex = Vect_cidx_get_field_index(&Map, options.field);
     if (findex > -1) {
-	n = Vect_cidx_get_num_cats_by_index(&Map, findex);
+	n = Vect_cidx_get_num_unique_cats_by_index(&Map, findex);
     }
     else {
 	n = 0;
@@ -80,6 +80,8 @@
     Values = (struct value *) G_calloc(n + 1, sizeof(struct value));
 
     /* prepopulate Values */
+    if (n > 0)
+	n = Vect_cidx_get_num_cats_by_index(&Map, findex);
     i = 0;
     Values[i].cat = -1;		/* features without category */
     Values[i].used = 0;



More information about the grass-commit mailing list