Back out use of palloc0 in place if palloc/MemSet. Seems constant len

to MemSet is a performance boost.
This commit is contained in:
Bruce Momjian 2002-11-11 03:02:20 +00:00
parent 5d283d89cb
commit 75fee4535d
38 changed files with 212 additions and 110 deletions

View File

@ -1442,7 +1442,8 @@ init_dblink_results(MemoryContext fn_mcxt)
oldcontext = MemoryContextSwitchTo(fn_mcxt); oldcontext = MemoryContextSwitchTo(fn_mcxt);
retval = (dblink_results *) palloc0(sizeof(dblink_results)); retval = (dblink_results *) palloc(sizeof(dblink_results));
MemSet(retval, 0, sizeof(dblink_results));
retval->tup_num = -1; retval->tup_num = -1;
retval->res_id_index = -1; retval->res_id_index = -1;

View File

@ -916,8 +916,10 @@ new_intArrayType(int num)
ArrayType *r; ArrayType *r;
int nbytes = ARR_OVERHEAD(NDIM) + sizeof(int) * num; int nbytes = ARR_OVERHEAD(NDIM) + sizeof(int) * num;
r = (ArrayType *) palloc0(nbytes); r = (ArrayType *) palloc(nbytes);
MemSet(r, 0, nbytes);
ARR_SIZE(r) = nbytes; ARR_SIZE(r) = nbytes;
ARR_NDIM(r) = NDIM; ARR_NDIM(r) = NDIM;
ARR_ELEMTYPE(r) = INT4OID; ARR_ELEMTYPE(r) = INT4OID;

View File

@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.61 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.62 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -121,8 +121,9 @@ index_formtuple(TupleDesc tupleDescriptor,
#endif #endif
size = MAXALIGN(size); /* be conservative */ size = MAXALIGN(size); /* be conservative */
tp = (char *) palloc0(size); tp = (char *) palloc(size);
tuple = (IndexTuple) tp; tuple = (IndexTuple) tp;
MemSet(tp, 0, size);
DataFill((char *) tp + hoff, DataFill((char *) tp + hoff,
tupleDescriptor, tupleDescriptor,

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.92 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.93 2002/11/11 03:02:18 momjian Exp $
* *
* NOTES * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
@ -60,7 +60,8 @@ CreateTemplateTupleDesc(int natts, bool hasoid)
{ {
uint32 size = natts * sizeof(Form_pg_attribute); uint32 size = natts * sizeof(Form_pg_attribute);
desc->attrs = (Form_pg_attribute *) palloc0(size); desc->attrs = (Form_pg_attribute *) palloc(size);
MemSet(desc->attrs, 0, size);
} }
else else
desc->attrs = NULL; desc->attrs = NULL;

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.97 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.98 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1316,8 +1316,10 @@ gistSplit(Relation r,
*/ */
if (r->rd_att->natts > 1) if (r->rd_att->natts > 1)
{ {
v.spl_idgrp = (int *) palloc0(sizeof(int) * (*len + 1)); v.spl_idgrp = (int *) palloc(sizeof(int) * (*len + 1));
v.spl_grpflag = (char *) palloc0(sizeof(char) * (*len + 1)); MemSet((void *) v.spl_idgrp, 0, sizeof(int) * (*len + 1));
v.spl_grpflag = (char *) palloc(sizeof(char) * (*len + 1));
MemSet((void *) v.spl_grpflag, 0, sizeof(char) * (*len + 1));
v.spl_ngrp = (int *) palloc(sizeof(int) * (*len + 1)); v.spl_ngrp = (int *) palloc(sizeof(int) * (*len + 1));
MaxGrpId = gistfindgroup(giststate, (GISTENTRY *) VARDATA(entryvec), &v); MaxGrpId = gistfindgroup(giststate, (GISTENTRY *) VARDATA(entryvec), &v);

View File

@ -35,7 +35,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.67 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.68 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -111,7 +111,9 @@ static void _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2);
BTSpool * BTSpool *
_bt_spoolinit(Relation index, bool isunique) _bt_spoolinit(Relation index, bool isunique)
{ {
BTSpool *btspool = (BTSpool *) palloc0(sizeof(BTSpool)); BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool));
MemSet((char *) btspool, 0, sizeof(BTSpool));
btspool->index = index; btspool->index = index;
btspool->isunique = isunique; btspool->isunique = isunique;
@ -205,7 +207,9 @@ _bt_blnewpage(Relation index, Buffer *buf, Page *page, int flags)
static BTPageState * static BTPageState *
_bt_pagestate(Relation index, int flags, int level) _bt_pagestate(Relation index, int flags, int level)
{ {
BTPageState *state = (BTPageState *) palloc0(sizeof(BTPageState)); BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState));
MemSet((char *) state, 0, sizeof(BTPageState));
/* create initial page */ /* create initial page */
_bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags); _bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags);

View File

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.34 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.35 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -103,7 +103,9 @@ rt_poly_union(PG_FUNCTION_ARGS)
POLYGON *b = PG_GETARG_POLYGON_P(1); POLYGON *b = PG_GETARG_POLYGON_P(1);
POLYGON *p; POLYGON *p;
p = (POLYGON *) palloc0(sizeof(POLYGON)); /* zero any holes */ p = (POLYGON *) palloc(sizeof(POLYGON));
MemSet((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
p->size = sizeof(POLYGON); p->size = sizeof(POLYGON);
p->npts = 0; p->npts = 0;
p->boundbox.high.x = Max(a->boundbox.high.x, b->boundbox.high.x); p->boundbox.high.x = Max(a->boundbox.high.x, b->boundbox.high.x);
@ -125,7 +127,9 @@ rt_poly_inter(PG_FUNCTION_ARGS)
POLYGON *b = PG_GETARG_POLYGON_P(1); POLYGON *b = PG_GETARG_POLYGON_P(1);
POLYGON *p; POLYGON *p;
p = (POLYGON *) palloc0(sizeof(POLYGON)); /* zero any holes */ p = (POLYGON *) palloc(sizeof(POLYGON));
MemSet((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
p->size = sizeof(POLYGON); p->size = sizeof(POLYGON);
p->npts = 0; p->npts = 0;
p->boundbox.high.x = Min(a->boundbox.high.x, b->boundbox.high.x); p->boundbox.high.x = Min(a->boundbox.high.x, b->boundbox.high.x);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.203 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.204 2002/11/11 03:02:18 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
@ -112,7 +112,8 @@ BuildFuncTupleDesc(Oid funcOid,
* Allocate and zero a tuple descriptor for a one-column tuple. * Allocate and zero a tuple descriptor for a one-column tuple.
*/ */
funcTupDesc = CreateTemplateTupleDesc(1, false); funcTupDesc = CreateTemplateTupleDesc(1, false);
funcTupDesc->attrs[0] = (Form_pg_attribute) palloc0(ATTRIBUTE_TUPLE_SIZE); funcTupDesc->attrs[0] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
MemSet(funcTupDesc->attrs[0], 0, ATTRIBUTE_TUPLE_SIZE);
/* /*
* Lookup the function to get its name and return type. * Lookup the function to get its name and return type.

View File

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

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.178 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.179 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -804,8 +804,9 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
elements = (Oid *) palloc(num_phys_attrs * sizeof(Oid)); elements = (Oid *) palloc(num_phys_attrs * sizeof(Oid));
defmap = (int *) palloc(num_phys_attrs * sizeof(int)); defmap = (int *) palloc(num_phys_attrs * sizeof(int));
defexprs = (Node **) palloc(num_phys_attrs * sizeof(Node *)); defexprs = (Node **) palloc(num_phys_attrs * sizeof(Node *));
constraintexprs = (Node **) palloc0(num_phys_attrs * sizeof(Node *)); constraintexprs = (Node **) palloc(num_phys_attrs * sizeof(Node *));
constraintconsts = (Const **) palloc(num_phys_attrs * sizeof(Const *)); constraintconsts = (Const **) palloc(num_phys_attrs * sizeof(Const *));
MemSet(constraintexprs, 0, num_phys_attrs * sizeof(Node *));
for (i = 0; i < num_phys_attrs; i++) 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) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California * Portions Copyright (c) 1994-5, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.91 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.92 2002/11/11 03:02:18 momjian Exp $
* *
*/ */
@ -164,7 +164,8 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
(double) endtime.tv_usec / 1000000.0; (double) endtime.tv_usec / 1000000.0;
} }
es = (ExplainState *) palloc0(sizeof(ExplainState)); es = (ExplainState *) palloc(sizeof(ExplainState));
MemSet(es, 0, sizeof(ExplainState));
es->printCost = true; /* default */ es->printCost = true; /* default */

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.182 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.183 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -106,8 +106,12 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate)
Assert(queryDesc != NULL); Assert(queryDesc != NULL);
if (queryDesc->plantree->nParamExec > 0) if (queryDesc->plantree->nParamExec > 0)
{
estate->es_param_exec_vals = (ParamExecData *) estate->es_param_exec_vals = (ParamExecData *)
palloc0(queryDesc->plantree->nParamExec * sizeof(ParamExecData)); palloc(queryDesc->plantree->nParamExec * sizeof(ParamExecData));
MemSet(estate->es_param_exec_vals, 0,
queryDesc->plantree->nParamExec * sizeof(ParamExecData));
}
/* /*
* Make our own private copy of the current query snapshot data. * Make our own private copy of the current query snapshot data.
@ -1788,12 +1792,17 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
*/ */
epqstate->es_evTupleNull = (bool *) palloc(rtsize * sizeof(bool)); epqstate->es_evTupleNull = (bool *) palloc(rtsize * sizeof(bool));
if (epq == NULL) if (epq == NULL)
{
/* first PQ stack entry */ /* first PQ stack entry */
epqstate->es_evTuple = (HeapTuple *) epqstate->es_evTuple = (HeapTuple *)
palloc0(rtsize * sizeof(HeapTuple)); palloc(rtsize * sizeof(HeapTuple));
memset(epqstate->es_evTuple, 0, rtsize * sizeof(HeapTuple));
}
else else
{
/* later stack entries share the same storage */ /* later stack entries share the same storage */
epqstate->es_evTuple = epq->estate.es_evTuple; epqstate->es_evTuple = epq->estate.es_evTuple;
}
} }
else else
{ {

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.58 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.59 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -121,7 +121,9 @@ init_execution_state(char *src, Oid *argOidVect, int nargs)
int i; int i;
ParamListInfo paramLI; ParamListInfo paramLI;
paramLI = (ParamListInfo) palloc0((nargs + 1) * sizeof(ParamListInfoData)); paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData));
MemSet(paramLI, 0, (nargs + 1) * sizeof(ParamListInfoData));
estate->es_param_list_info = paramLI; estate->es_param_list_info = paramLI;
@ -183,7 +185,8 @@ init_sql_fcache(FmgrInfo *finfo)
typeStruct = (Form_pg_type) GETSTRUCT(typeTuple); typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
fcache = (SQLFunctionCachePtr) palloc0(sizeof(SQLFunctionCache)); fcache = (SQLFunctionCachePtr) palloc(sizeof(SQLFunctionCache));
MemSet(fcache, 0, sizeof(SQLFunctionCache));
/* /*
* get the type length and by-value flag from the type tuple * get the type length and by-value flag from the type tuple

View File

@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.93 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.94 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -651,7 +651,8 @@ lookup_hash_entry(Agg *node, TupleTableSlot *slot)
MemoryContextSwitchTo(aggstate->aggcontext); MemoryContextSwitchTo(aggstate->aggcontext);
entrysize = sizeof(AggHashEntryData) + entrysize = sizeof(AggHashEntryData) +
(aggstate->numaggs - 1) * sizeof(AggStatePerGroupData); (aggstate->numaggs - 1) * sizeof(AggStatePerGroupData);
entry = (AggHashEntry) palloc0(entrysize); entry = (AggHashEntry) palloc(entrysize);
MemSet(entry, 0, entrysize);
entry->hashkey = hashkey; entry->hashkey = hashkey;
entry->firstTuple = heap_copytuple(tuple); entry->firstTuple = heap_copytuple(tuple);
@ -887,8 +888,9 @@ agg_retrieve_direct(Agg *node)
Datum *dvalues; Datum *dvalues;
char *dnulls; char *dnulls;
dvalues = (Datum *) palloc0(sizeof(Datum) * tupType->natts); dvalues = (Datum *) palloc(sizeof(Datum) * tupType->natts);
dnulls = (char *) palloc(sizeof(char) * tupType->natts); dnulls = (char *) palloc(sizeof(char) * tupType->natts);
MemSet(dvalues, 0, sizeof(Datum) * tupType->natts);
MemSet(dnulls, 'n', sizeof(char) * tupType->natts); MemSet(dnulls, 'n', sizeof(char) * tupType->natts);
nullsTuple = heap_formtuple(tupType, dvalues, dnulls); nullsTuple = heap_formtuple(tupType, dvalues, dnulls);
ExecStoreTuple(nullsTuple, ExecStoreTuple(nullsTuple,
@ -1168,10 +1170,13 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
* allocate my private per-agg working storage * allocate my private per-agg working storage
*/ */
econtext = aggstate->csstate.cstate.cs_ExprContext; econtext = aggstate->csstate.cstate.cs_ExprContext;
econtext->ecxt_aggvalues = (Datum *) palloc0(sizeof(Datum) * numaggs); econtext->ecxt_aggvalues = (Datum *) palloc(sizeof(Datum) * numaggs);
econtext->ecxt_aggnulls = (bool *) palloc0(sizeof(bool) * 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);
peragg = (AggStatePerAgg) palloc0(sizeof(AggStatePerAggData) * numaggs); peragg = (AggStatePerAgg) palloc(sizeof(AggStatePerAggData) * numaggs);
MemSet(peragg, 0, sizeof(AggStatePerAggData) * numaggs);
aggstate->peragg = peragg; aggstate->peragg = peragg;
if (node->aggstrategy == AGG_HASHED) if (node->aggstrategy == AGG_HASHED)
@ -1183,7 +1188,8 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
{ {
AggStatePerGroup pergroup; AggStatePerGroup pergroup;
pergroup = (AggStatePerGroup) palloc0(sizeof(AggStatePerGroupData) * numaggs); pergroup = (AggStatePerGroup) palloc(sizeof(AggStatePerGroupData) * numaggs);
MemSet(pergroup, 0, sizeof(AggStatePerGroupData) * numaggs);
aggstate->pergroup = pergroup; aggstate->pergroup = pergroup;
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.48 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.49 2002/11/11 03:02:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -166,7 +166,8 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
appendplans = node->appendplans; appendplans = node->appendplans;
nplans = length(appendplans); nplans = length(appendplans);
initialized = (bool *) palloc0(nplans * sizeof(bool)); initialized = (bool *) palloc(nplans * sizeof(bool));
MemSet(initialized, 0, nplans * sizeof(bool));
/* /*
* create new AppendState for our append node * create new AppendState for our append node

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.38 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.39 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -50,9 +50,11 @@ ExtractSortKeys(Sort *sortnode,
*/ */
if (keycount <= 0) if (keycount <= 0)
elog(ERROR, "ExtractSortKeys: keycount <= 0"); elog(ERROR, "ExtractSortKeys: keycount <= 0");
sortOps = (Oid *) palloc0(keycount * sizeof(Oid)); sortOps = (Oid *) palloc(keycount * sizeof(Oid));
MemSet(sortOps, 0, keycount * sizeof(Oid));
*sortOperators = sortOps; *sortOperators = sortOps;
attNos = (AttrNumber *) palloc0(keycount * sizeof(AttrNumber)); attNos = (AttrNumber *) palloc(keycount * sizeof(AttrNumber));
MemSet(attNos, 0, keycount * sizeof(AttrNumber));
*attNums = attNos; *attNums = attNos;
/* /*

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.76 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.77 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -783,8 +783,9 @@ SPI_cursor_open(char *name, void *plan, Datum *Values, char *Nulls)
{ {
ParamListInfo paramLI; ParamListInfo paramLI;
paramLI = (ParamListInfo) palloc0((spiplan->nargs + 1) * paramLI = (ParamListInfo) palloc((spiplan->nargs + 1) *
sizeof(ParamListInfoData)); sizeof(ParamListInfoData));
MemSet(paramLI, 0, (spiplan->nargs + 1) * sizeof(ParamListInfoData));
eState->es_param_list_info = paramLI; eState->es_param_list_info = paramLI;
for (k = 0; k < spiplan->nargs; paramLI++, k++) for (k = 0; k < spiplan->nargs; paramLI++, k++)
@ -1192,7 +1193,9 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount)
int k; int k;
paramLI = (ParamListInfo) paramLI = (ParamListInfo)
palloc0((nargs + 1) * sizeof(ParamListInfoData)); palloc((nargs + 1) * sizeof(ParamListInfoData));
MemSet(paramLI, 0,
(nargs + 1) * sizeof(ParamListInfoData));
state->es_param_list_info = paramLI; state->es_param_list_info = paramLI;
for (k = 0; k < plan->nargs; paramLI++, k++) for (k = 0; k < plan->nargs; paramLI++, k++)

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.90 2002/11/10 07:25:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.91 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -460,7 +460,8 @@ make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels)
* joinitems[j] is a list of all the j-item rels. Initially we set * joinitems[j] is a list of all the j-item rels. Initially we set
* joinitems[1] to represent all the single-jointree-item relations. * joinitems[1] to represent all the single-jointree-item relations.
*/ */
joinitems = (List **) palloc0((levels_needed + 1) * sizeof(List *)); joinitems = (List **) palloc((levels_needed + 1) * sizeof(List *));
MemSet(joinitems, 0, (levels_needed + 1) * sizeof(List *));
joinitems[1] = initial_rels; joinitems[1] = initial_rels;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.140 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.141 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1070,7 +1070,8 @@ gen_cross_product(InhPaths *arginh, int nargs)
/* compute the cross product from right to left */ /* compute the cross product from right to left */
for (;;) for (;;)
{ {
oneres = (Oid *) palloc0(FUNC_MAX_ARGS * sizeof(Oid)); oneres = (Oid *) palloc(FUNC_MAX_ARGS * sizeof(Oid));
MemSet(oneres, 0, FUNC_MAX_ARGS * sizeof(Oid));
for (i = nargs - 1; i >= 0 && cur[i] > arginh[i].nsupers; i--) for (i = nargs - 1; i >= 0 && cur[i] > arginh[i].nsupers; i--)
continue; continue;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.70 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.71 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -40,7 +40,8 @@ make_parsestate(ParseState *parentParseState)
{ {
ParseState *pstate; ParseState *pstate;
pstate = palloc0(sizeof(ParseState)); pstate = palloc(sizeof(ParseState));
MemSet(pstate, 0, sizeof(ParseState));
pstate->parentParseState = parentParseState; pstate->parentParseState = parentParseState;
pstate->p_last_resno = 1; pstate->p_last_resno = 1;

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.291 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.292 2002/11/11 03:02:19 momjian Exp $
* *
* NOTES * NOTES
* *
@ -1092,8 +1092,10 @@ ProcessStartupPacket(Port *port, bool SSLdone)
if (len < sizeof(ProtocolVersion) || len > sizeof(StartupPacket)) if (len < sizeof(ProtocolVersion) || len > sizeof(StartupPacket))
elog(FATAL, "invalid length of startup packet"); elog(FATAL, "invalid length of startup packet");
buf = palloc(sizeof(StartupPacket));
/* Ensure we see zeroes for any bytes not sent */ /* Ensure we see zeroes for any bytes not sent */
buf = palloc0(sizeof(StartupPacket)); MemSet(buf, 0, sizeof(StartupPacket));
if (pq_getbytes(buf, len) == EOF) if (pq_getbytes(buf, len) == EOF)
{ {

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.81 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.82 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -248,7 +248,8 @@ makeacl(int n)
if (n < 0) if (n < 0)
elog(ERROR, "makeacl: invalid size: %d", n); elog(ERROR, "makeacl: invalid size: %d", n);
size = ACL_N_SIZE(n); size = ACL_N_SIZE(n);
new_acl = (Acl *) palloc0(size); new_acl = (Acl *) palloc(size);
MemSet((char *) new_acl, 0, size);
new_acl->size = size; new_acl->size = size;
new_acl->ndim = 1; new_acl->ndim = 1;
new_acl->flags = 0; new_acl->flags = 0;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.83 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.84 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -235,7 +235,8 @@ array_in(PG_FUNCTION_ARGS)
if (nitems == 0) if (nitems == 0)
{ {
/* Return empty array */ /* Return empty array */
retval = (ArrayType *) palloc0(sizeof(ArrayType)); retval = (ArrayType *) palloc(sizeof(ArrayType));
MemSet(retval, 0, sizeof(ArrayType));
retval->size = sizeof(ArrayType); retval->size = sizeof(ArrayType);
retval->elemtype = element_type; retval->elemtype = element_type;
PG_RETURN_ARRAYTYPE_P(retval); PG_RETURN_ARRAYTYPE_P(retval);
@ -248,7 +249,8 @@ array_in(PG_FUNCTION_ARGS)
typmod, typdelim, typlen, typbyval, typalign, typmod, typdelim, typlen, typbyval, typalign,
&nbytes); &nbytes);
nbytes += ARR_OVERHEAD(ndim); nbytes += ARR_OVERHEAD(ndim);
retval = (ArrayType *) palloc0(nbytes); retval = (ArrayType *) palloc(nbytes);
MemSet(retval, 0, nbytes);
retval->size = nbytes; retval->size = nbytes;
retval->ndim = ndim; retval->ndim = ndim;
retval->elemtype = element_type; retval->elemtype = element_type;
@ -395,7 +397,8 @@ ReadArrayStr(char *arrayStr,
prod[MAXDIM]; prod[MAXDIM];
mda_get_prod(ndim, dim, prod); mda_get_prod(ndim, dim, prod);
values = (Datum *) palloc0(nitems * sizeof(Datum)); values = (Datum *) palloc(nitems * sizeof(Datum));
MemSet(values, 0, nitems * sizeof(Datum));
MemSet(indx, 0, sizeof(indx)); MemSet(indx, 0, sizeof(indx));
/* read array enclosed within {} */ /* read array enclosed within {} */
@ -511,7 +514,10 @@ ReadArrayStr(char *arrayStr,
if (!typbyval) if (!typbyval)
for (i = 0; i < nitems; i++) for (i = 0; i < nitems; i++)
if (values[i] == (Datum) 0) if (values[i] == (Datum) 0)
values[i] = PointerGetDatum(palloc0(typlen)); {
values[i] = PointerGetDatum(palloc(typlen));
MemSet(DatumGetPointer(values[i]), 0, typlen);
}
} }
else else
{ {
@ -1587,7 +1593,8 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType)
/* Allocate and initialize the result array */ /* Allocate and initialize the result array */
nbytes += ARR_OVERHEAD(ndim); nbytes += ARR_OVERHEAD(ndim);
result = (ArrayType *) palloc0(nbytes); result = (ArrayType *) palloc(nbytes);
MemSet(result, 0, nbytes);
result->size = nbytes; result->size = nbytes;
result->ndim = ndim; result->ndim = ndim;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.69 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.70 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -3130,8 +3130,9 @@ poly_in(PG_FUNCTION_ARGS)
elog(ERROR, "Bad polygon external representation '%s'", str); elog(ERROR, "Bad polygon external representation '%s'", str);
size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts;
poly = (POLYGON *) palloc0(size); /* zero any holes */ poly = (POLYGON *) palloc(size);
MemSet((char *) poly, 0, size); /* zero any holes */
poly->size = size; poly->size = size;
poly->npts = npts; poly->npts = npts;
@ -4451,7 +4452,9 @@ circle_poly(PG_FUNCTION_ARGS)
if (base_size / npts != sizeof(poly->p[0]) || size <= base_size) if (base_size / npts != sizeof(poly->p[0]) || size <= base_size)
elog(ERROR, "too many points requested"); elog(ERROR, "too many points requested");
poly = (POLYGON *) palloc0(size); /* zero any holes */ poly = (POLYGON *) palloc(size);
MemSet(poly, 0, size); /* zero any holes */
poly->size = size; poly->size = size;
poly->npts = npts; poly->npts = npts;

View File

@ -3,7 +3,7 @@
* is for IP V4 CIDR notation, but prepared for V6: just * is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate. * add the necessary bits where the comments indicate.
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.36 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.37 2002/11/11 03:02:19 momjian Exp $
* *
* Jon Postel RIP 16 Oct 1998 * Jon Postel RIP 16 Oct 1998
*/ */
@ -51,8 +51,9 @@ network_in(char *src, int type)
int bits; int bits;
inet *dst; inet *dst;
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
/* make sure any unused bits in a CIDR value are zeroed */ /* make sure any unused bits in a CIDR value are zeroed */
dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct));
/* First, try for an IP V4 address: */ /* First, try for an IP V4 address: */
ip_family(dst) = AF_INET; ip_family(dst) = AF_INET;
@ -493,8 +494,9 @@ network_broadcast(PG_FUNCTION_ARGS)
inet *ip = PG_GETARG_INET_P(0); inet *ip = PG_GETARG_INET_P(0);
inet *dst; inet *dst;
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
/* make sure any unused bits are zeroed */ /* make sure any unused bits are zeroed */
dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct));
if (ip_family(ip) == AF_INET) if (ip_family(ip) == AF_INET)
{ {
@ -532,8 +534,9 @@ network_network(PG_FUNCTION_ARGS)
inet *ip = PG_GETARG_INET_P(0); inet *ip = PG_GETARG_INET_P(0);
inet *dst; inet *dst;
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
/* make sure any unused bits are zeroed */ /* make sure any unused bits are zeroed */
dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct));
if (ip_family(ip) == AF_INET) if (ip_family(ip) == AF_INET)
{ {
@ -571,8 +574,9 @@ network_netmask(PG_FUNCTION_ARGS)
inet *ip = PG_GETARG_INET_P(0); inet *ip = PG_GETARG_INET_P(0);
inet *dst; inet *dst;
dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct));
/* make sure any unused bits are zeroed */ /* make sure any unused bits are zeroed */
dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct));
if (ip_family(ip) == AF_INET) if (ip_family(ip) == AF_INET)
{ {

View File

@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.27 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.28 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -107,8 +107,9 @@ bit_in(PG_FUNCTION_ARGS)
bitlen, atttypmod); bitlen, atttypmod);
len = VARBITTOTALLEN(atttypmod); len = VARBITTOTALLEN(atttypmod);
result = (VarBit *) palloc(len);
/* set to 0 so that *r is always initialised and string is zero-padded */ /* set to 0 so that *r is always initialised and string is zero-padded */
result = (VarBit *) palloc0(len); MemSet(result, 0, len);
VARATT_SIZEP(result) = len; VARATT_SIZEP(result) = len;
VARBITLEN(result) = atttypmod; VARBITLEN(result) = atttypmod;
@ -231,8 +232,9 @@ bit(PG_FUNCTION_ARGS)
VARBITLEN(arg), len); VARBITLEN(arg), len);
rlen = VARBITTOTALLEN(len); rlen = VARBITTOTALLEN(len);
result = (VarBit *) palloc(rlen);
/* set to 0 so that string is zero-padded */ /* set to 0 so that string is zero-padded */
result = (VarBit *) palloc0(rlen); MemSet(result, 0, rlen);
VARATT_SIZEP(result) = rlen; VARATT_SIZEP(result) = rlen;
VARBITLEN(result) = len; VARBITLEN(result) = len;
@ -314,8 +316,9 @@ varbit_in(PG_FUNCTION_ARGS)
atttypmod); atttypmod);
len = VARBITTOTALLEN(bitlen); len = VARBITTOTALLEN(bitlen);
result = (VarBit *) palloc(len);
/* set to 0 so that *r is always initialised and string is zero-padded */ /* set to 0 so that *r is always initialised and string is zero-padded */
result = (VarBit *) palloc0(len); MemSet(result, 0, len);
VARATT_SIZEP(result) = len; VARATT_SIZEP(result) = len;
VARBITLEN(result) = Min(bitlen, atttypmod); VARBITLEN(result) = Min(bitlen, atttypmod);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.100 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.101 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -808,7 +808,8 @@ InitCatCache(int id,
* *
* Note: we assume zeroing initializes the Dllist headers correctly * Note: we assume zeroing initializes the Dllist headers correctly
*/ */
cp = (CatCache *) palloc0(sizeof(CatCache) + NCCBUCKETS * sizeof(Dllist)); cp = (CatCache *) palloc(sizeof(CatCache) + NCCBUCKETS * sizeof(Dllist));
MemSet((char *) cp, 0, sizeof(CatCache) + NCCBUCKETS * sizeof(Dllist));
/* /*
* initialize the cache's relation information for the relation * initialize the cache's relation information for the relation

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.178 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.179 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1348,9 +1348,13 @@ formrdesc(const char *relationName,
/* /*
* allocate new relation desc * allocate new relation desc
*/
relation = (Relation) palloc(sizeof(RelationData));
/*
* clear all fields of reldesc * clear all fields of reldesc
*/ */
relation = (Relation) palloc0(sizeof(RelationData)); MemSet((char *) relation, 0, sizeof(RelationData));
relation->rd_targblock = InvalidBlockNumber; relation->rd_targblock = InvalidBlockNumber;
/* make sure relation is marked as having no open file yet */ /* make sure relation is marked as having no open file yet */
@ -1376,7 +1380,8 @@ formrdesc(const char *relationName,
* get us launched. RelationCacheInitializePhase2() will read the * get us launched. RelationCacheInitializePhase2() will read the
* real data from pg_class and replace what we've done here. * real data from pg_class and replace what we've done here.
*/ */
relation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); relation->rd_rel = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
MemSet(relation->rd_rel, 0, CLASS_TUPLE_SIZE);
namestrcpy(&relation->rd_rel->relname, relationName); namestrcpy(&relation->rd_rel->relname, relationName);
relation->rd_rel->relnamespace = PG_CATALOG_NAMESPACE; relation->rd_rel->relnamespace = PG_CATALOG_NAMESPACE;
@ -2049,7 +2054,8 @@ RelationBuildLocalRelation(const char *relname,
/* /*
* allocate a new relation descriptor and fill in basic state fields. * allocate a new relation descriptor and fill in basic state fields.
*/ */
rel = (Relation) palloc0(sizeof(RelationData)); rel = (Relation) palloc(sizeof(RelationData));
MemSet((char *) rel, 0, sizeof(RelationData));
rel->rd_targblock = InvalidBlockNumber; rel->rd_targblock = InvalidBlockNumber;
@ -2087,7 +2093,8 @@ RelationBuildLocalRelation(const char *relname,
/* /*
* initialize relation tuple form (caller may add/override data later) * initialize relation tuple form (caller may add/override data later)
*/ */
rel->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); rel->rd_rel = (Form_pg_class) palloc(CLASS_TUPLE_SIZE);
MemSet((char *) rel->rd_rel, 0, CLASS_TUPLE_SIZE);
namestrcpy(&rel->rd_rel->relname, relname); namestrcpy(&rel->rd_rel->relname, relname);
rel->rd_rel->relnamespace = relnamespace; rel->rd_rel->relnamespace = relnamespace;

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.64 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.65 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1550,8 +1550,9 @@ Int64GetDatum(int64 X)
* with zeroes in the unused bits. This is needed so that, for * with zeroes in the unused bits. This is needed so that, for
* example, hash join of int8 will behave properly. * example, hash join of int8 will behave properly.
*/ */
int64 *retval = (int64 *) palloc0(Max(sizeof(int64), 8)); int64 *retval = (int64 *) palloc(Max(sizeof(int64), 8));
MemSet(retval, 0, Max(sizeof(int64), 8));
*retval = X; *retval = X;
return PointerGetDatum(retval); return PointerGetDatum(retval);
#endif /* INT64_IS_BUSTED */ #endif /* INT64_IS_BUSTED */

View File

@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.30 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.31 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -414,7 +414,9 @@ tuplesort_begin_common(bool randomAccess)
{ {
Tuplesortstate *state; Tuplesortstate *state;
state = (Tuplesortstate *) palloc0(sizeof(Tuplesortstate)); state = (Tuplesortstate *) palloc(sizeof(Tuplesortstate));
MemSet((char *) state, 0, sizeof(Tuplesortstate));
state->status = TSS_INITIAL; state->status = TSS_INITIAL;
state->randomAccess = randomAccess; state->randomAccess = randomAccess;
@ -457,9 +459,11 @@ tuplesort_begin_heap(TupleDesc tupDesc,
state->tupDesc = tupDesc; state->tupDesc = tupDesc;
state->nKeys = nkeys; state->nKeys = nkeys;
state->scanKeys = (ScanKey) palloc0(nkeys * sizeof(ScanKeyData)); state->scanKeys = (ScanKey) palloc(nkeys * sizeof(ScanKeyData));
MemSet(state->scanKeys, 0, nkeys * sizeof(ScanKeyData));
state->sortFnKinds = (SortFunctionKind *) state->sortFnKinds = (SortFunctionKind *)
palloc0(nkeys * sizeof(SortFunctionKind)); palloc(nkeys * sizeof(SortFunctionKind));
MemSet(state->sortFnKinds, 0, nkeys * sizeof(SortFunctionKind));
for (i = 0; i < nkeys; i++) for (i = 0; i < nkeys; i++)
{ {

View File

@ -26,7 +26,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.8 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.9 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -197,7 +197,9 @@ tuplestore_begin_common(bool randomAccess, int maxKBytes)
{ {
Tuplestorestate *state; Tuplestorestate *state;
state = (Tuplestorestate *) palloc0(sizeof(Tuplestorestate)); state = (Tuplestorestate *) palloc(sizeof(Tuplestorestate));
MemSet((char *) state, 0, sizeof(Tuplestorestate));
state->status = TSS_INITIAL; state->status = TSS_INITIAL;
state->randomAccess = randomAccess; state->randomAccess = randomAccess;

View File

@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: c.h,v 1.130 2002/10/24 03:11:05 momjian Exp $ * $Id: c.h,v 1.131 2002/11/11 03:02:19 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -586,8 +586,7 @@ typedef NameData *Name;
int _val = (val); \ int _val = (val); \
Size _len = (len); \ Size _len = (len); \
\ \
if ((((long) _start) & INT_ALIGN_MASK) == 0 && \ if ((( ((long) _start) | _len) & INT_ALIGN_MASK) == 0 && \
(_len & INT_ALIGN_MASK) == 0 && \
_val == 0 && \ _val == 0 && \
_len <= MEMSET_LOOP_LIMIT) \ _len <= MEMSET_LOOP_LIMIT) \
{ \ { \

View File

@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.67 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.68 2002/11/11 03:02:19 momjian Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
@ -1008,7 +1008,7 @@ exec_stmt_perform(PLpgSQL_execstate * estate, PLpgSQL_stmt_perform * stmt)
*/ */
if (expr->plan == NULL) if (expr->plan == NULL)
exec_prepare_plan(estate, expr); exec_prepare_plan(estate, expr);
rc = exec_run_select(estate, expr, 0, NULL); rc = exec_run_select(estate, expr, 0, NULL);
if (rc != SPI_OK_SELECT) if (rc != SPI_OK_SELECT)
elog(ERROR, "query \"%s\" didn't return data", expr->query); elog(ERROR, "query \"%s\" didn't return data", expr->query);
@ -1627,8 +1627,9 @@ exec_stmt_return_next(PLpgSQL_execstate * estate,
if (natts != stmt->row->nfields) if (natts != stmt->row->nfields)
elog(ERROR, "Wrong record type supplied in RETURN NEXT"); elog(ERROR, "Wrong record type supplied in RETURN NEXT");
dvalues = (Datum *) palloc0(natts * sizeof(Datum)); dvalues = (Datum *) palloc(natts * sizeof(Datum));
nulls = (char *) palloc(natts * sizeof(char)); nulls = (char *) palloc(natts * sizeof(char));
MemSet(dvalues, 0, natts * sizeof(Datum));
MemSet(nulls, 'n', natts); MemSet(nulls, 'n', natts);
for (i = 0; i < natts; i++) for (i = 0; i < natts; i++)

View File

@ -1,5 +1,5 @@
/* /*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.52 2002/11/10 07:25:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.53 2002/11/11 03:02:20 momjian Exp $
*/ */
#include "postgres.h" #include "postgres.h"
@ -300,11 +300,12 @@ reverse_name(char *string)
int len; int len;
char *new_string; char *new_string;
if (!(new_string = palloc0(NAMEDATALEN))) if (!(new_string = palloc(NAMEDATALEN)))
{ {
fprintf(stderr, "reverse_name: palloc failed\n"); fprintf(stderr, "reverse_name: palloc failed\n");
return NULL; return NULL;
} }
MemSet(new_string, 0, NAMEDATALEN);
for (i = 0; i < NAMEDATALEN && string[i]; ++i) for (i = 0; i < NAMEDATALEN && string[i]; ++i)
; ;
if (i == NAMEDATALEN || !string[i]) if (i == NAMEDATALEN || !string[i])