mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Merge palloc()/MemSet(0) calls into a single palloc0() call.
This commit is contained in:
@ -27,7 +27,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.181 2002/11/09 23:56:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.182 2002/11/10 07:25:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -106,12 +106,8 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
|
||||
Assert(queryDesc != NULL);
|
||||
|
||||
if (queryDesc->plantree->nParamExec > 0)
|
||||
{
|
||||
estate->es_param_exec_vals = (ParamExecData *)
|
||||
palloc(queryDesc->plantree->nParamExec * sizeof(ParamExecData));
|
||||
MemSet(estate->es_param_exec_vals, 0,
|
||||
queryDesc->plantree->nParamExec * sizeof(ParamExecData));
|
||||
}
|
||||
palloc0(queryDesc->plantree->nParamExec * sizeof(ParamExecData));
|
||||
|
||||
/*
|
||||
* Make our own private copy of the current query snapshot data.
|
||||
@ -1792,17 +1788,12 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
|
||||
*/
|
||||
epqstate->es_evTupleNull = (bool *) palloc(rtsize * sizeof(bool));
|
||||
if (epq == NULL)
|
||||
{
|
||||
/* first PQ stack entry */
|
||||
epqstate->es_evTuple = (HeapTuple *)
|
||||
palloc(rtsize * sizeof(HeapTuple));
|
||||
memset(epqstate->es_evTuple, 0, rtsize * sizeof(HeapTuple));
|
||||
}
|
||||
palloc0(rtsize * sizeof(HeapTuple));
|
||||
else
|
||||
{
|
||||
/* later stack entries share the same storage */
|
||||
epqstate->es_evTuple = epq->estate.es_evTuple;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.57 2002/09/04 20:31:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.58 2002/11/10 07:25:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -121,9 +121,7 @@ init_execution_state(char *src, Oid *argOidVect, int nargs)
|
||||
int i;
|
||||
ParamListInfo paramLI;
|
||||
|
||||
paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
MemSet(paramLI, 0, (nargs + 1) * sizeof(ParamListInfoData));
|
||||
paramLI = (ParamListInfo) palloc0((nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
estate->es_param_list_info = paramLI;
|
||||
|
||||
@ -185,8 +183,7 @@ init_sql_fcache(FmgrInfo *finfo)
|
||||
|
||||
typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
|
||||
|
||||
fcache = (SQLFunctionCachePtr) palloc(sizeof(SQLFunctionCache));
|
||||
MemSet(fcache, 0, sizeof(SQLFunctionCache));
|
||||
fcache = (SQLFunctionCachePtr) palloc0(sizeof(SQLFunctionCache));
|
||||
|
||||
/*
|
||||
* get the type length and by-value flag from the type tuple
|
||||
|
@ -45,7 +45,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.92 2002/11/06 22:31:23 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.93 2002/11/10 07:25:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -651,8 +651,7 @@ lookup_hash_entry(Agg *node, TupleTableSlot *slot)
|
||||
MemoryContextSwitchTo(aggstate->aggcontext);
|
||||
entrysize = sizeof(AggHashEntryData) +
|
||||
(aggstate->numaggs - 1) * sizeof(AggStatePerGroupData);
|
||||
entry = (AggHashEntry) palloc(entrysize);
|
||||
MemSet(entry, 0, entrysize);
|
||||
entry = (AggHashEntry) palloc0(entrysize);
|
||||
|
||||
entry->hashkey = hashkey;
|
||||
entry->firstTuple = heap_copytuple(tuple);
|
||||
@ -888,9 +887,8 @@ agg_retrieve_direct(Agg *node)
|
||||
Datum *dvalues;
|
||||
char *dnulls;
|
||||
|
||||
dvalues = (Datum *) palloc(sizeof(Datum) * tupType->natts);
|
||||
dvalues = (Datum *) palloc0(sizeof(Datum) * tupType->natts);
|
||||
dnulls = (char *) palloc(sizeof(char) * tupType->natts);
|
||||
MemSet(dvalues, 0, sizeof(Datum) * tupType->natts);
|
||||
MemSet(dnulls, 'n', sizeof(char) * tupType->natts);
|
||||
nullsTuple = heap_formtuple(tupType, dvalues, dnulls);
|
||||
ExecStoreTuple(nullsTuple,
|
||||
@ -1170,13 +1168,10 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
|
||||
* allocate my private per-agg working storage
|
||||
*/
|
||||
econtext = aggstate->csstate.cstate.cs_ExprContext;
|
||||
econtext->ecxt_aggvalues = (Datum *) palloc(sizeof(Datum) * numaggs);
|
||||
MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * numaggs);
|
||||
econtext->ecxt_aggnulls = (bool *) palloc(sizeof(bool) * numaggs);
|
||||
MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * numaggs);
|
||||
econtext->ecxt_aggvalues = (Datum *) palloc0(sizeof(Datum) * numaggs);
|
||||
econtext->ecxt_aggnulls = (bool *) palloc0(sizeof(bool) * numaggs);
|
||||
|
||||
peragg = (AggStatePerAgg) palloc(sizeof(AggStatePerAggData) * numaggs);
|
||||
MemSet(peragg, 0, sizeof(AggStatePerAggData) * numaggs);
|
||||
peragg = (AggStatePerAgg) palloc0(sizeof(AggStatePerAggData) * numaggs);
|
||||
aggstate->peragg = peragg;
|
||||
|
||||
if (node->aggstrategy == AGG_HASHED)
|
||||
@ -1188,8 +1183,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
|
||||
{
|
||||
AggStatePerGroup pergroup;
|
||||
|
||||
pergroup = (AggStatePerGroup) palloc(sizeof(AggStatePerGroupData) * numaggs);
|
||||
MemSet(pergroup, 0, sizeof(AggStatePerGroupData) * numaggs);
|
||||
pergroup = (AggStatePerGroup) palloc0(sizeof(AggStatePerGroupData) * numaggs);
|
||||
aggstate->pergroup = pergroup;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.47 2002/11/01 19:33:09 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.48 2002/11/10 07:25:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -166,8 +166,7 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
|
||||
appendplans = node->appendplans;
|
||||
nplans = length(appendplans);
|
||||
|
||||
initialized = (bool *) palloc(nplans * sizeof(bool));
|
||||
MemSet(initialized, 0, nplans * sizeof(bool));
|
||||
initialized = (bool *) palloc0(nplans * sizeof(bool));
|
||||
|
||||
/*
|
||||
* create new AppendState for our append node
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.37 2002/11/02 15:54:13 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.38 2002/11/10 07:25:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -50,11 +50,9 @@ ExtractSortKeys(Sort *sortnode,
|
||||
*/
|
||||
if (keycount <= 0)
|
||||
elog(ERROR, "ExtractSortKeys: keycount <= 0");
|
||||
sortOps = (Oid *) palloc(keycount * sizeof(Oid));
|
||||
MemSet(sortOps, 0, keycount * sizeof(Oid));
|
||||
sortOps = (Oid *) palloc0(keycount * sizeof(Oid));
|
||||
*sortOperators = sortOps;
|
||||
attNos = (AttrNumber *) palloc(keycount * sizeof(AttrNumber));
|
||||
MemSet(attNos, 0, keycount * sizeof(AttrNumber));
|
||||
attNos = (AttrNumber *) palloc0(keycount * sizeof(AttrNumber));
|
||||
*attNums = attNos;
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.75 2002/10/14 23:49:20 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.76 2002/11/10 07:25:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -783,9 +783,8 @@ SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls)
|
||||
{
|
||||
ParamListInfo paramLI;
|
||||
|
||||
paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) *
|
||||
paramLI = (ParamListInfo) palloc0((spiplan->nargs + 1) *
|
||||
sizeof(ParamListInfoData));
|
||||
MemSet(paramLI, 0, (spiplan->nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
eState->es_param_list_info = paramLI;
|
||||
for (k = 0; k < spiplan->nargs; paramLI++, k++)
|
||||
@ -1193,9 +1192,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount)
|
||||
int k;
|
||||
|
||||
paramLI = (ParamListInfo)
|
||||
palloc((nargs + 1) * sizeof(ParamListInfoData));
|
||||
MemSet(paramLI, 0,
|
||||
(nargs + 1) * sizeof(ParamListInfoData));
|
||||
palloc0((nargs + 1) * sizeof(ParamListInfoData));
|
||||
|
||||
state->es_param_list_info = paramLI;
|
||||
for (k = 0; k < plan->nargs; paramLI++, k++)
|
||||
|
Reference in New Issue
Block a user