]> granicus.if.org Git - postgis/commitdiff
palloc return value doesn't need to be checked, because if out of memory, function...
authorJorge Arévalo <jorge.arevalo at deimos-space.com>
Thu, 14 Apr 2011 16:29:21 +0000 (16:29 +0000)
committerJorge Arévalo <jorge.arevalo at deimos-space.com>
Thu, 14 Apr 2011 16:29:21 +0000 (16:29 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7032 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c

index 6e9fac492102ada1fd6728685a441fb47f67aa9a..4824acdd8265116744036147903c12f08355917d 100644 (file)
@@ -1288,10 +1288,10 @@ Datum RASTER_getBandPixelTypeName(PG_FUNCTION_ARGS)
     pixtype = rt_band_get_pixtype(ctx, band);
 
     result = palloc(VARHDRSZ + name_size);
-    if ( ! result ) {
-        elog(ERROR, "RASTER_getBandPixelTypeName: Could not allocate memory for output text object");
-        PG_RETURN_NULL();
-    }
+    /* We don't need to check for NULL pointer, because if out of memory, palloc
+     * exit via elog(ERROR). It never returns NULL.
+     */
+
     memset(VARDATA(result), 0, name_size);
     ptr = (char *)result + VARHDRSZ;
 
@@ -1612,10 +1612,7 @@ Datum RASTER_getBandPath(PG_FUNCTION_ARGS)
     }
 
     result = (text *) palloc(VARHDRSZ + strlen(bandpath) + 1);
-    if ( ! result ) {
-        elog(ERROR, "RASTER_getBandPath: Could not allocate memory for output text object");
-        PG_RETURN_NULL();
-    }
+    
     SET_VARSIZE(result, VARHDRSZ + strlen(bandpath) + 1);
 
     strcpy((char *) VARDATA(result), bandpath);
@@ -2691,11 +2688,6 @@ rt_pg_alloc(size_t size)
 
     result = palloc(size);
 
-    if ( ! result )
-    {
-        ereport(ERROR, (errmsg_internal("Out of virtual memory")));
-        return NULL;
-    }
     return result;
 }