]> granicus.if.org Git - postgis/commitdiff
Corrected use of pfree instead of PG_FREE_IF_COPY
authorBborie Park <bkpark at ucdavis.edu>
Thu, 7 Feb 2013 17:16:54 +0000 (17:16 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 7 Feb 2013 17:16:54 +0000 (17:16 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11084 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c

index 97394765872e04d0dd775c8bd253283e09e85cbe..141d4eb49e2a7db96cac3598bec1ccd6e8a22da5 100644 (file)
@@ -808,23 +808,23 @@ Datum RASTER_minPossibleValue(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(RASTER_in);
 Datum RASTER_in(PG_FUNCTION_ARGS)
 {
-    rt_raster raster;
-    char *hexwkb = PG_GETARG_CSTRING(0);
-    void *result = NULL;
-
-               POSTGIS_RT_DEBUG(3, "Starting");
+       rt_raster raster;
+       char *hexwkb = PG_GETARG_CSTRING(0);
+       void *result = NULL;
 
-    raster = rt_raster_from_hexwkb(hexwkb, strlen(hexwkb));
-    result = rt_raster_serialize(raster);
+       POSTGIS_RT_DEBUG(3, "Starting");
 
-    SET_VARSIZE(result, ((rt_pgraster*)result)->size);
+       raster = rt_raster_from_hexwkb(hexwkb, strlen(hexwkb));
+       if (raster == NULL)
+               PG_RETURN_NULL();
 
-    rt_raster_destroy(raster);
+       result = rt_raster_serialize(raster);
+       rt_raster_destroy(raster);
+       if (result == NULL)
+               PG_RETURN_NULL();
 
-    if ( NULL != result )
-        PG_RETURN_POINTER(result);
-    else
-        PG_RETURN_NULL();
+       SET_VARSIZE(result, ((rt_pgraster*)result)->size);
+       PG_RETURN_POINTER(result);
 }
 
 /**
@@ -1208,9 +1208,8 @@ Datum RASTER_makeEmpty(PG_FUNCTION_ARGS)
                skewx, skewy, srid);
 
        raster = rt_raster_new(width, height);
-       if (!raster) {
+       if (raster == NULL)
                PG_RETURN_NULL(); /* error was supposedly printed already */
-       }
 
        rt_raster_set_scale(raster, scalex, scaley);
        rt_raster_set_offsets(raster, ipx, ipy);
@@ -3077,7 +3076,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                default:
                        elog(ERROR, "RASTER_setPixelValuesArray: Invalid data type for new values");
                        rt_raster_destroy(raster);
-                       pfree(pgraster);
+                       PG_FREE_IF_COPY(pgraster, 0);
                        PG_RETURN_NULL();
                        break;
        }
@@ -3117,7 +3116,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                        pfree(nulls);
                }
                rt_raster_destroy(raster);
-               pfree(pgraster);
+               PG_FREE_IF_COPY(pgraster, 0);
                PG_RETURN_NULL();
        }
 
@@ -3129,7 +3128,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                pfree(elements);
                pfree(nulls);
                rt_raster_destroy(raster);
-               pfree(pgraster);
+               PG_FREE_IF_COPY(pgraster, 0);
                PG_RETURN_NULL();
        }
 
@@ -3178,7 +3177,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                                elog(ERROR, "RASTER_setPixelValuesArray: Invalid data type for noset flags");
                                pfree(pixval);
                                rt_raster_destroy(raster);
-                               pfree(pgraster);
+                               PG_FREE_IF_COPY(pgraster, 0);
                                PG_RETURN_NULL();
                                break;
                }
@@ -3220,7 +3219,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                                pfree(nulls);
                        }
                        rt_raster_destroy(raster);
-                       pfree(pgraster);
+                       PG_FREE_IF_COPY(pgraster, 0);
                        PG_RETURN_NULL();
                }
 
@@ -3329,7 +3328,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
                                elog(ERROR, "Cannot get value of pixel.  Returning NULL");
                                pfree(pixval);
                                rt_raster_destroy(raster);
-                               pfree(pgraster);
+                               PG_FREE_IF_COPY(pgraster, 0);
                                PG_RETURN_NULL();
                        }
 
@@ -3350,7 +3349,7 @@ Datum RASTER_setPixelValuesArray(PG_FUNCTION_ARGS)
        /* serialize new raster */
        pgrtn = rt_raster_serialize(raster);
        rt_raster_destroy(raster);
-       pfree(pgraster);
+       PG_FREE_IF_COPY(pgraster, 0);
        if (!pgrtn)
                PG_RETURN_NULL();