From 2f6f61231e56758cda67cbb30b13b77e0fb6de96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jorge=20Ar=C3=A9valo?= Date: Thu, 14 Apr 2011 16:29:21 +0000 Subject: [PATCH] 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 --- raster/rt_pg/rt_pg.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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; } -- 2.50.1