[GRASS-SVN] r38735 - grass/trunk/lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 15 02:39:11 EDT 2009


Author: martinl
Date: 2009-08-15 02:39:08 -0400 (Sat, 15 Aug 2009)
New Revision: 38735

Modified:
   grass/trunk/lib/ogsf/GS2.c
   grass/trunk/lib/ogsf/gs.c
Log:
marisn: Don't use invalid pointers for debug output. Fixes #417
	(backported from devbr6, r38672)


Modified: grass/trunk/lib/ogsf/GS2.c
===================================================================
--- grass/trunk/lib/ogsf/GS2.c	2009-08-15 06:22:33 UTC (rev 38734)
+++ grass/trunk/lib/ogsf/GS2.c	2009-08-15 06:39:08 UTC (rev 38735)
@@ -1010,7 +1010,7 @@
 }
 
 /*!
-   \brief Unset ?
+   \brief Unset Scaled Difference surface
  */
 void GS_unset_SDsurf(void)
 {
@@ -1021,7 +1021,7 @@
 }
 
 /*!
-   \brief Set ?
+   \brief Set surface as Scaled Difference surface
 
    \param id surface id
 

Modified: grass/trunk/lib/ogsf/gs.c
===================================================================
--- grass/trunk/lib/ogsf/gs.c	2009-08-15 06:22:33 UTC (rev 38734)
+++ grass/trunk/lib/ogsf/gs.c	2009-08-15 06:39:08 UTC (rev 38735)
@@ -235,12 +235,12 @@
     geosurf *ps;
     int i;
 
-    G_debug(5, "gs_init_surf() id=%d", gs->gsurf_id);
-
     if (!gs) {
 	return (-1);
     }
 
+    G_debug(5, "gs_init_surf() id=%d", gs->gsurf_id);
+
     /* default attributes */
     for (i = 0; i < MAX_ATTS; i++) {
 	gs->att[i].att_src = NOTSET_ATT;
@@ -282,7 +282,7 @@
     gs->norms = NULL;
 
     gs->draw_mode = DM_GOURAUD;
-    
+
     /* default z_exag value */
     if (gs->gsurf_id == FIRST_SURF_ID) {
 	gs->z_exag = 1.0;
@@ -655,8 +655,8 @@
  */
 int gs_get_att_src(geosurf * gs, int desc)
 {
-    G_debug(5, "gs_get_att_src(): id=%d desc=%d", gs->gsurf_id, desc);
-
+    if (gs)
+	G_debug(5, "gs_get_att_src(): id=%d, desc=%d", gs->gsurf_id, desc);
     if (!LEGAL_ATT(desc)) {
 	return (-1);
     }
@@ -683,10 +683,9 @@
     typbuff *tb;
     geosurf *gsref;
 
-    G_debug(5, "gs_get_att_typbuff(): id=%d desc=%d to_write=%d",
-	    gs->gsurf_id, desc, to_write);
-
     if (gs) {
+	G_debug(5, "gs_get_att_typbuff(): id=%d desc=%d to_write=%d",
+		gs->gsurf_id, desc, to_write);
 	if ((tb = gsds_get_typbuff(gs->att[desc].hdata, to_write))) {
 	    tb->tfunc = NULL;
 
@@ -827,8 +826,9 @@
  */
 int gs_set_att_src(geosurf * gs, int desc, int src)
 {
-    G_debug(5, "gs_set_att_src(): id=%d desc=%d src=%d",
-	    gs->gsurf_id, desc, src);
+    if (gs)
+	G_debug(5, "gs_set_att_src(): id=%d desc=%d src=%d",
+		gs->gsurf_id, desc, src);
 
     /* check if old source was MAP_ATT, free buff */
     if (MAP_ATT == gs_get_att_src(gs, desc)) {
@@ -871,10 +871,10 @@
  */
 int gs_set_att_const(geosurf * gs, int desc, float constant)
 {
-    G_debug(5, "gs_set_att_const(): id=%d, desc=%d, const=%f",
-	    gs->gsurf_id, desc, constant);
 
     if (gs) {
+	G_debug(5, "gs_set_att_const(): id=%d, desc=%d, const=%f",
+		gs->gsurf_id, desc, constant);
 	gs->att[desc].constant = constant;
 
 	if (ATT_MASK == desc) {



More information about the grass-commit mailing list