From: Jorge Arévalo Date: Thu, 14 Apr 2011 16:29:21 +0000 (+0000) Subject: palloc return value doesn't need to be checked, because if out of memory, function... X-Git-Tag: 2.0.0alpha1~1770 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f6f61231e56758cda67cbb30b13b77e0fb6de96;p=postgis palloc return value doesn't need to be checked, because if out of memory, function ends with elog(ERROR). It never returns NULL. git-svn-id: http://svn.osgeo.org/postgis/trunk@7032 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index 6e9fac492..4824acdd8 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -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; }