diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-06-05 19:48:09 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-06-05 19:48:09 +0000 |
commit | c3a153afed84e29dac664bdc6123724a9e3a906f (patch) | |
tree | 8249c3dd76ddc9874656ec36f763227327c0a70e /src/backend/commands/analyze.c | |
parent | 24a1e20f146f3b4b88f0f5189a7631c511796310 (diff) | |
download | postgresql-c3a153afed84e29dac664bdc6123724a9e3a906f.tar.gz postgresql-c3a153afed84e29dac664bdc6123724a9e3a906f.zip |
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.)
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r-- | src/backend/commands/analyze.c | 11 |
1 files changed, 5 insertions, 6 deletions
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++) |