[GRASS-SVN] r32626 - in grass/trunk: include lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 7 17:26:18 EDT 2008
Author: glynn
Date: 2008-08-07 17:26:18 -0400 (Thu, 07 Aug 2008)
New Revision: 32626
Modified:
grass/trunk/include/gisdefs.h
grass/trunk/lib/gis/cats.c
Log:
Use "const" where appropriate
Modified: grass/trunk/include/gisdefs.h
===================================================================
--- grass/trunk/include/gisdefs.h 2008-08-07 21:13:13 UTC (rev 32625)
+++ grass/trunk/include/gisdefs.h 2008-08-07 21:26:18 UTC (rev 32626)
@@ -121,10 +121,10 @@
char *G_get_d_raster_cat(DCELL *, struct Categories *);
char *G_get_raster_cat(void *, struct Categories *, RASTER_MAP_TYPE);
int G_unmark_raster_cats(struct Categories *);
-int G_mark_c_raster_cats(CELL *, int, struct Categories *);
-int G_mark_f_raster_cats(FCELL *, int, struct Categories *);
-int G_mark_d_raster_cats(DCELL *, int, struct Categories *);
-int G_mark_raster_cats(void *, int, struct Categories *, RASTER_MAP_TYPE);
+int G_mark_c_raster_cats(const CELL *, int, struct Categories *);
+int G_mark_f_raster_cats(const FCELL *, int, struct Categories *);
+int G_mark_d_raster_cats(const DCELL *, int, struct Categories *);
+int G_mark_raster_cats(const void *, int, struct Categories *, RASTER_MAP_TYPE);
int G_rewind_raster_cats(struct Categories *);
char *G_get_next_marked_d_raster_cat(struct Categories *, DCELL *, DCELL *,
long *);
@@ -134,16 +134,16 @@
long *);
char *G_get_next_marked_raster_cat(struct Categories *, void *, void *,
long *, RASTER_MAP_TYPE);
-int G_set_cat(CELL, char *, struct Categories *);
-int G_set_c_raster_cat(CELL *, CELL *, char *, struct Categories *);
-int G_set_f_raster_cat(FCELL *, FCELL *, char *, struct Categories *);
-int G_set_d_raster_cat(DCELL *, DCELL *, char *, struct Categories *);
-int G_set_raster_cat(void *, void *, char *, struct Categories *,
+int G_set_cat(CELL, const char *, struct Categories *);
+int G_set_c_raster_cat(const CELL *, const CELL *, const char *, struct Categories *);
+int G_set_f_raster_cat(const FCELL *, const FCELL *, const char *, struct Categories *);
+int G_set_d_raster_cat(const DCELL *, const DCELL *, const char *, struct Categories *);
+int G_set_raster_cat(const void *, const void *, const char *, struct Categories *,
RASTER_MAP_TYPE);
-int G_write_cats(char *, struct Categories *);
-int G_write_raster_cats(char *, struct Categories *);
-int G_write_vector_cats(char *, struct Categories *);
-int G__write_cats(char *, char *, struct Categories *);
+int G_write_cats(const char *, struct Categories *);
+int G_write_raster_cats(const char *, struct Categories *);
+int G_write_vector_cats(const char *, struct Categories *);
+int G__write_cats(const char *, const char *, struct Categories *);
char *G_get_ith_d_raster_cat(const struct Categories *, int, DCELL *,
DCELL *);
char *G_get_ith_f_raster_cat(const struct Categories *, int, void *, void *);
Modified: grass/trunk/lib/gis/cats.c
===================================================================
--- grass/trunk/lib/gis/cats.c 2008-08-07 21:13:13 UTC (rev 32625)
+++ grass/trunk/lib/gis/cats.c 2008-08-07 21:26:18 UTC (rev 32626)
@@ -61,8 +61,8 @@
**********************************************************************
*
* G_read_[raster]_cats (name, mapset, pcats)
- * char *name name of cell file
- * char *mapset mapset that cell file belongs to
+ * const char *name name of cell file
+ * const char *mapset mapset that cell file belongs to
* struct Categories *pcats structure to hold category info
*
* Reads the category information associated with cell file "name"
@@ -88,8 +88,8 @@
**********************************************************************
*
* G_read_vector_cats (name, mapset, pcats)
- * char *name name of vector map
- * char *mapset mapset that vector map belongs to
+ * const char *name name of vector map
+ * const char *mapset mapset that vector map belongs to
* struct Categories *pcats structure to hold category info
*
*
@@ -164,7 +164,7 @@
*
* G_init_cats (ncats, title, pcats)
* CELL ncats number of categories
- * char *title cell title
+ * const char *title cell title
* struct Categories *pcats structure to hold category info
*
* Initializes the cats structure for subsequent calls to G_set_cat()
@@ -229,7 +229,7 @@
**********************************************************************
*
* G_init_raster_cats (title, pcats)
- * char *title cell title
+ * const char *title cell title
* struct Categories *pcats structure to hold category info
*
* Initializes the cats structure for subsequent calls to G_set_cat()
@@ -237,7 +237,7 @@
**********************************************************************
*
* G_set_[raster]_cats_fmt (fmt, m1, a1, m2, a2, pcats)
- * char *fmt user form of the equation format
+ * const char *fmt user form of the equation format
* float m1,a1,m2,a2 coefficients
* struct Categories *pcats structure to hold category info
*
@@ -247,7 +247,7 @@
**********************************************************************
*
* G_set_[raster]_cats_title (title, pcats)
- * char *title cell file title
+ * const char *title cell file title
* struct Categories *pcats structure holding category info
*
* Store title as cell file in cats structure
@@ -257,7 +257,7 @@
*
* G_set_cat (num, label, pcats)
* CELL num category number
- * char *label category label
+ * const char *label category label
* struct Categories *pcats structure to hold category info
*
* Adds the string buff to represent category "num" in category structure
@@ -269,7 +269,7 @@
*
* G_set_[f/d/c]_raster_cat (&val1, &val2, label, pcats)
* [D/F]CELL *val1, *val2; pointers to raster values
- * char *label category label
+ * const char *label category label
* struct Categories *pcats structure to hold category info
*
* Adds the label for range val1 through val2 in category structure
@@ -281,7 +281,7 @@
*
* G_set_raster_cat (val1, val2, label, pcats, data_type)
* void *val1, *val2; pointers to raster values
- * char *label category label
+ * const char *label category label
* struct Categories *pcats structure to hold category info
* RASTER_MAP_TYPE data_type type of raster cell
*
@@ -293,7 +293,7 @@
**********************************************************************
*
* G_write_[raster]_cats (name, pcats)
- * char *name name of cell file
+ * const char *name name of cell file
* struct Categories *pcats structure holding category info
*
* Writes the category information associated with cell file "name"
@@ -304,7 +304,7 @@
**********************************************************************
*
* G_write_vector_cats (name, pcats)
- * char *name name of vector map
+ * const char *name name of vector map
* struct Categories *pcats structure holding category info
*
* Writes the category information associated with vector map "name"
@@ -750,7 +750,7 @@
* \return int
*/
-int G_mark_c_raster_cats(CELL * rast_row, /* raster row to update stats */
+int G_mark_c_raster_cats(const CELL * rast_row, /* raster row to update stats */
int ncols, struct Categories *pcats)
{ /* structure to hold category info */
G_mark_raster_cats(rast_row, ncols, pcats, CELL_TYPE);
@@ -772,7 +772,7 @@
* \return int
*/
-int G_mark_f_raster_cats(FCELL * rast_row, /* raster row to update stats */
+int G_mark_f_raster_cats(const FCELL * rast_row, /* raster row to update stats */
int ncols, struct Categories *pcats)
{ /* structure to hold category info */
G_mark_raster_cats(rast_row, ncols, pcats, FCELL_TYPE);
@@ -794,7 +794,7 @@
* \return int
*/
-int G_mark_d_raster_cats(DCELL * rast_row, /* raster row to update stats */
+int G_mark_d_raster_cats(const DCELL * rast_row, /* raster row to update stats */
int ncols, struct Categories *pcats)
{ /* structure to hold category info */
G_mark_raster_cats(rast_row, ncols, pcats, DCELL_TYPE);
@@ -818,7 +818,7 @@
* \return int
*/
-int G_mark_raster_cats(void *rast_row, /* raster row to update stats */
+int G_mark_raster_cats(const void *rast_row, /* raster row to update stats */
int ncols, struct Categories *pcats, /* structure to hold category info */
RASTER_MAP_TYPE data_type)
{
@@ -996,11 +996,9 @@
* \return int
*/
-int G_set_cat(CELL num, char *label, struct Categories *pcats)
+int G_set_cat(CELL num, const char *label, struct Categories *pcats)
{
- CELL tmp = num;
-
- return G_set_c_raster_cat(&tmp, &tmp, label, pcats);
+ return G_set_c_raster_cat(&num, &num, label, pcats);
}
@@ -1016,8 +1014,8 @@
* \return int
*/
-int G_set_c_raster_cat(CELL * rast1, CELL * rast2,
- char *label, struct Categories *pcats)
+int G_set_c_raster_cat(const CELL * rast1, const CELL * rast2,
+ const char *label, struct Categories *pcats)
{
return G_set_raster_cat(rast1, rast2, label, pcats, CELL_TYPE);
}
@@ -1035,8 +1033,8 @@
* \return int
*/
-int G_set_f_raster_cat(FCELL * rast1, FCELL * rast2,
- char *label, struct Categories *pcats)
+int G_set_f_raster_cat(const FCELL * rast1, const FCELL * rast2,
+ const char *label, struct Categories *pcats)
{
return G_set_raster_cat(rast1, rast2, label, pcats, FCELL_TYPE);
}
@@ -1054,8 +1052,8 @@
* \return int
*/
-int G_set_d_raster_cat(DCELL * rast1, DCELL * rast2,
- char *label, struct Categories *pcats)
+int G_set_d_raster_cat(const DCELL * rast1, const DCELL * rast2,
+ const char *label, struct Categories *pcats)
{
long len;
DCELL dtmp1, dtmp2;
@@ -1155,8 +1153,8 @@
* \return int
*/
-int G_set_raster_cat(void *rast1, void *rast2,
- char *label,
+int G_set_raster_cat(const void *rast1, const void *rast2,
+ const char *label,
struct Categories *pcats, RASTER_MAP_TYPE data_type)
{
DCELL val1, val2;
@@ -1180,7 +1178,7 @@
* \return int
*/
-int G_write_cats(char *name, struct Categories *cats)
+int G_write_cats(const char *name, struct Categories *cats)
{
return G__write_cats("cats", name, cats);
}
@@ -1196,7 +1194,7 @@
* \return int
*/
-int G_write_raster_cats(char *name, struct Categories *cats)
+int G_write_raster_cats(const char *name, struct Categories *cats)
{
return G__write_cats("cats", name, cats);
}
@@ -1216,12 +1214,12 @@
* \return int
*/
-int G_write_vector_cats(char *name, struct Categories *cats)
+int G_write_vector_cats(const char *name, struct Categories *cats)
{
return G__write_cats("dig_cats", name, cats);
}
-int G__write_cats(char *element, char *name, struct Categories *cats)
+int G__write_cats(const char *element, const char *name, struct Categories *cats)
{
FILE *fd;
int i, fp_map;
More information about the grass-commit
mailing list