1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

Merge palloc()/MemSet(0) calls into a single palloc0() call.

This commit is contained in:
Bruce Momjian
2002-11-10 07:25:14 +00:00
parent 78822b328c
commit 8fee9615cc
37 changed files with 107 additions and 210 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.47 2002/09/23 20:43:40 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.48 2002/11/10 07:25:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -423,8 +423,7 @@ examine_attribute(Relation onerel, int attnum)
* If we have "=" then we're at least able to do the minimal
* algorithm, so start filling in a VacAttrStats struct.
*/
stats = (VacAttrStats *) palloc(sizeof(VacAttrStats));
MemSet(stats, 0, sizeof(VacAttrStats));
stats = (VacAttrStats *) palloc0(sizeof(VacAttrStats));
stats->attnum = attnum;
stats->attr = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
memcpy(stats->attr, attr, ATTRIBUTE_TUPLE_SIZE);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.177 2002/10/19 00:25:36 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.178 2002/11/10 07:25:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -804,9 +804,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
elements = (Oid *) palloc(num_phys_attrs * sizeof(Oid));
defmap = (int *) palloc(num_phys_attrs * sizeof(int));
defexprs = (Node **) palloc(num_phys_attrs * sizeof(Node *));
constraintexprs = (Node **) palloc(num_phys_attrs * sizeof(Node *));
constraintexprs = (Node **) palloc0(num_phys_attrs * sizeof(Node *));
constraintconsts = (Const **) palloc(num_phys_attrs * sizeof(Const *));
MemSet(constraintexprs, 0, num_phys_attrs * sizeof(Node *));
for (i = 0; i < num_phys_attrs; i++)
{

View File

@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.90 2002/11/06 00:00:43 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.91 2002/11/10 07:25:13 momjian Exp $
*
*/
@ -164,8 +164,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
(double) endtime.tv_usec / 1000000.0;
}
es = (ExplainState *) palloc(sizeof(ExplainState));
MemSet(es, 0, sizeof(ExplainState));
es = (ExplainState *) palloc0(sizeof(ExplainState));
es->printCost = true; /* default */

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.6 2002/10/04 22:19:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.7 2002/11/10 07:25:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -124,12 +124,9 @@ DefineOpClass(CreateOpClassStmt *stmt)
* do this mainly so that we can detect duplicate strategy numbers and
* support-proc numbers.
*/
operators = (Oid *) palloc(sizeof(Oid) * numOperators);
MemSet(operators, 0, sizeof(Oid) * numOperators);
procedures = (Oid *) palloc(sizeof(Oid) * numProcs);
MemSet(procedures, 0, sizeof(Oid) * numProcs);
recheck = (bool *) palloc(sizeof(bool) * numOperators);
MemSet(recheck, 0, sizeof(bool) * numOperators);
operators = (Oid *) palloc0(sizeof(Oid) * numOperators);
procedures = (Oid *) palloc0(sizeof(Oid) * numProcs);
recheck = (bool *) palloc0(sizeof(bool) * numOperators);
/*
* Scan the "items" list to obtain additional info.

View File

@ -6,7 +6,7 @@
* Copyright (c) 2002, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.4 2002/09/20 03:45:08 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.5 2002/11/10 07:25:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -116,8 +116,7 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest)
if (nargs != length(stmt->params))
elog(ERROR, "ExecuteQuery: wrong number of arguments");
paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData));
MemSet(paramLI, 0, (nargs + 1) * sizeof(ParamListInfoData));
paramLI = (ParamListInfo) palloc0((nargs + 1) * sizeof(ParamListInfoData));
foreach(l, stmt->params)
{

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.136 2002/10/21 19:55:49 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.137 2002/11/10 07:25:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -94,7 +94,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint)
constrrelid = RangeVarGetRelid(stmt->constrrel, false);
else if (stmt->isconstraint)
{
/*
/*
* If this trigger is a constraint (and a foreign key one)
* then we really need a constrrelid. Since we don't have one,
* we'll try to generate one from the argument information.
@ -779,8 +779,7 @@ RelationBuildTriggers(Relation relation)
RelationGetRelationName(relation));
/* Build trigdesc */
trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc));
MemSet(trigdesc, 0, sizeof(TriggerDesc));
trigdesc = (TriggerDesc *) palloc0(sizeof(TriggerDesc));
trigdesc->triggers = triggers;
trigdesc->numtriggers = ntrigs;
for (found = 0; found < ntrigs; found++)
@ -1146,12 +1145,8 @@ ExecBRInsertTriggers(EState *estate, ResultRelInfo *relinfo,
/* Allocate cache space for fmgr lookup info, if not done yet */
if (relinfo->ri_TrigFunctions == NULL)
{
relinfo->ri_TrigFunctions = (FmgrInfo *)
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(relinfo->ri_TrigFunctions, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
@ -1206,12 +1201,8 @@ ExecBRDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
/* Allocate cache space for fmgr lookup info, if not done yet */
if (relinfo->ri_TrigFunctions == NULL)
{
relinfo->ri_TrigFunctions = (FmgrInfo *)
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(relinfo->ri_TrigFunctions, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = TRIGGER_EVENT_DELETE | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
@ -1282,12 +1273,8 @@ ExecBRUpdateTriggers(EState *estate, ResultRelInfo *relinfo,
/* Allocate cache space for fmgr lookup info, if not done yet */
if (relinfo->ri_TrigFunctions == NULL)
{
relinfo->ri_TrigFunctions = (FmgrInfo *)
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(relinfo->ri_TrigFunctions, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
}
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
LocTriggerData.type = T_TriggerData;
LocTriggerData.tg_event = TRIGGER_EVENT_UPDATE | TRIGGER_EVENT_ROW | TRIGGER_EVENT_BEFORE;
@ -1769,9 +1756,7 @@ deferredTriggerInvokeEvents(bool immediate_only)
* Allocate space to cache fmgr lookup info for triggers.
*/
finfo = (FmgrInfo *)
palloc(trigdesc->numtriggers * sizeof(FmgrInfo));
MemSet(finfo, 0,
trigdesc->numtriggers * sizeof(FmgrInfo));
palloc0(trigdesc->numtriggers * sizeof(FmgrInfo));
}
DeferredTriggerExecute(event, i, rel, trigdesc, finfo,

View File

@ -31,7 +31,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.20 2002/09/20 19:56:01 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.21 2002/11/10 07:25:13 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -147,8 +147,7 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt)
vacuum_set_xid_limits(vacstmt, onerel->rd_rel->relisshared,
&OldestXmin, &FreezeLimit);
vacrelstats = (LVRelStats *) palloc(sizeof(LVRelStats));
MemSet(vacrelstats, 0, sizeof(LVRelStats));
vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats));
/* Open all indexes of the relation */
vac_open_indexes(onerel, &nindexes, &Irel);