From c3a153afed84e29dac664bdc6123724a9e3a906f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 5 Jun 2004 19:48:09 +0000 Subject: Tweak palloc/repalloc to allow zero bytes to be requested, as per recent proposal. Eliminate several dozen now-unnecessary hacks to avoid palloc(0). (It's likely there are more that I didn't find.) --- src/backend/commands/analyze.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/backend/commands/analyze.c') diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 4efaf653ede..cf1c2e9f1d2 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.73 2004/05/26 04:41:09 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.74 2004/06/05 19:48:07 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -226,9 +226,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) else { attr_cnt = onerel->rd_att->natts; - /* +1 here is just to avoid palloc(0) with zero-column table */ - vacattrstats = (VacAttrStats **) palloc((attr_cnt + 1) * - sizeof(VacAttrStats *)); + vacattrstats = (VacAttrStats **) + palloc(attr_cnt * sizeof(VacAttrStats *)); tcnt = 0; for (i = 1; i <= attr_cnt; i++) { @@ -505,8 +504,8 @@ compute_index_stats(Relation onerel, double totalrows, estate); /* Compute and save index expression values */ - exprvals = (Datum *) palloc((numrows * attr_cnt + 1) * sizeof(Datum)); - exprnulls = (bool *) palloc((numrows * attr_cnt + 1) * sizeof(bool)); + exprvals = (Datum *) palloc(numrows * attr_cnt * sizeof(Datum)); + exprnulls = (bool *) palloc(numrows * attr_cnt * sizeof(bool)); numindexrows = 0; tcnt = 0; for (rowno = 0; rowno < numrows; rowno++) -- cgit v1.2.3