diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-11-13 00:39:48 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-11-13 00:39:48 +0000 |
commit | 9b12ab6d5dd6c40ac112456c820a8dc199fc6e16 (patch) | |
tree | 9ee7a9977161f5343d4ffcf6b8c5453c963aae2e | |
parent | aaa3a0caa6c3e4dacd950e2dc3c1691222c50965 (diff) | |
download | postgresql-9b12ab6d5dd6c40ac112456c820a8dc199fc6e16.tar.gz |
Add new palloc0 call as merge of palloc and MemSet(0).
37 files changed, 107 insertions, 210 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 67a9d30d64..8cbce09d1b 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -1442,8 +1442,7 @@ init_dblink_results(MemoryContext fn_mcxt) oldcontext = MemoryContextSwitchTo(fn_mcxt); - retval = (dblink_results *) palloc(sizeof(dblink_results)); - MemSet(retval, 0, sizeof(dblink_results)); + retval = (dblink_results *) palloc0(sizeof(dblink_results)); retval->tup_num = -1; retval->res_id_index = -1; diff --git a/contrib/intarray/_int.c b/contrib/intarray/_int.c index dc674e09ff..325d504d84 100644 --- a/contrib/intarray/_int.c +++ b/contrib/intarray/_int.c @@ -916,10 +916,8 @@ new_intArrayType(int num) ArrayType *r; int nbytes = ARR_OVERHEAD(NDIM) + sizeof(int) * num; - r = (ArrayType *) palloc(nbytes); + r = (ArrayType *) palloc0(nbytes); - MemSet(r, 0, nbytes); - ARR_SIZE(r) = nbytes; ARR_NDIM(r) = NDIM; ARR_ELEMTYPE(r) = INT4OID; diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 03b4cd1440..7275984e64 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.62 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.63 2002/11/13 00:39:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,9 +121,8 @@ index_formtuple(TupleDesc tupleDescriptor, #endif size = MAXALIGN(size); /* be conservative */ - tp = (char *) palloc(size); + tp = (char *) palloc0(size); tuple = (IndexTuple) tp; - MemSet(tp, 0, size); DataFill((char *) tp + hoff, tupleDescriptor, diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index a2e777b002..b6c28675a9 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.93 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.94 2002/11/13 00:39:46 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -60,8 +60,7 @@ CreateTemplateTupleDesc(int natts, bool hasoid) { uint32 size = natts * sizeof(Form_pg_attribute); - desc->attrs = (Form_pg_attribute *) palloc(size); - MemSet(desc->attrs, 0, size); + desc->attrs = (Form_pg_attribute *) palloc0(size); } else desc->attrs = NULL; diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 6c76e02570..6591e76644 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.98 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.99 2002/11/13 00:39:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1316,10 +1316,8 @@ gistSplit(Relation r, */ if (r->rd_att->natts > 1) { - v.spl_idgrp = (int *) palloc(sizeof(int) * (*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_idgrp = (int *) palloc0(sizeof(int) * (*len + 1)); + v.spl_grpflag = (char *) palloc0(sizeof(char) * (*len + 1)); v.spl_ngrp = (int *) palloc(sizeof(int) * (*len + 1)); MaxGrpId = gistfindgroup(giststate, (GISTENTRY *) VARDATA(entryvec), &v); diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 68ed6a9829..9496a75175 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -35,7 +35,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.68 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.69 2002/11/13 00:39:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -111,9 +111,7 @@ static void _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2); BTSpool * _bt_spoolinit(Relation index, bool isunique) { - BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool)); - - MemSet((char *) btspool, 0, sizeof(BTSpool)); + BTSpool *btspool = (BTSpool *) palloc0(sizeof(BTSpool)); btspool->index = index; btspool->isunique = isunique; @@ -207,9 +205,7 @@ _bt_blnewpage(Relation index, Buffer *buf, Page *page, int flags) static BTPageState * _bt_pagestate(Relation index, int flags, int level) { - BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState)); - - MemSet((char *) state, 0, sizeof(BTPageState)); + BTPageState *state = (BTPageState *) palloc0(sizeof(BTPageState)); /* create initial page */ _bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags); diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c index 4e52847da8..643d11db03 100644 --- a/src/backend/access/rtree/rtproc.c +++ b/src/backend/access/rtree/rtproc.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.35 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.36 2002/11/13 00:39:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,9 +103,7 @@ rt_poly_union(PG_FUNCTION_ARGS) POLYGON *b = PG_GETARG_POLYGON_P(1); POLYGON *p; - p = (POLYGON *) palloc(sizeof(POLYGON)); - - MemSet((char *) p, 0, sizeof(POLYGON)); /* zero any holes */ + p = (POLYGON *) palloc0(sizeof(POLYGON)); /* zero any holes */ p->size = sizeof(POLYGON); p->npts = 0; p->boundbox.high.x = Max(a->boundbox.high.x, b->boundbox.high.x); @@ -127,9 +125,7 @@ rt_poly_inter(PG_FUNCTION_ARGS) POLYGON *b = PG_GETARG_POLYGON_P(1); POLYGON *p; - p = (POLYGON *) palloc(sizeof(POLYGON)); - - MemSet((char *) p, 0, sizeof(POLYGON)); /* zero any holes */ + p = (POLYGON *) palloc0(sizeof(POLYGON)); /* zero any holes */ p->size = sizeof(POLYGON); p->npts = 0; p->boundbox.high.x = Min(a->boundbox.high.x, b->boundbox.high.x); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 45463eca38..cdac597ae5 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.204 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.205 2002/11/13 00:39:46 momjian Exp $ * * * INTERFACE ROUTINES @@ -112,8 +112,7 @@ BuildFuncTupleDesc(Oid funcOid, * Allocate and zero a tuple descriptor for a one-column tuple. */ funcTupDesc = CreateTemplateTupleDesc(1, false); - funcTupDesc->attrs[0] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE); - MemSet(funcTupDesc->attrs[0], 0, ATTRIBUTE_TUPLE_SIZE); + funcTupDesc->attrs[0] = (Form_pg_attribute) palloc0(ATTRIBUTE_TUPLE_SIZE); /* * Lookup the function to get its name and return type. diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index a6fffc7cb4..e15320225d 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.49 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.50 2002/11/13 00:39:46 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); diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 6143c92ec3..8dbde72be4 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.179 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.180 2002/11/13 00:39:46 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++) { diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index e6075dd28f..0e6ca88fd4 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -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.92 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.93 2002/11/13 00:39:46 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 */ diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index 11e05c0b4e..f67a1a6e81 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.8 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.9 2002/11/13 00:39:46 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. diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 7ce70299ce..eb65be0d56 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -6,7 +6,7 @@ * Copyright (c) 2002, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.6 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.7 2002/11/13 00:39:46 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) { diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 01bacc0447..5c56a7ccfc 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -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.138 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.139 2002/11/13 00:39:46 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, diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 1591f74766..2974eb1bc3 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -31,7 +31,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.22 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.23 2002/11/13 00:39:46 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); diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index efad76fcc1..e775ae030e 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -27,7 +27,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.184 2002/11/11 22:19:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.185 2002/11/13 00:39:46 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 { diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 105784fda4..71166d9096 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.59 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.60 2002/11/13 00:39:47 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 diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 63c5bc20b4..5fa82ee9fa 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -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.94 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.95 2002/11/13 00:39:47 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; } diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index 970da155f7..9d0e564222 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.49 2002/11/11 03:02:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.50 2002/11/13 00:39:47 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 diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c index bed63e0361..05f36427be 100644 --- a/src/backend/executor/nodeSort.c +++ b/src/backend/executor/nodeSort.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.39 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.40 2002/11/13 00:39:47 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; /* diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index eed5a5a090..6e897e423e 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.77 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.78 2002/11/13 00:39:47 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++) diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 6ff9544134..107641399d 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.91 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.92 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -460,8 +460,7 @@ 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[1] to represent all the single-jointree-item relations. */ - joinitems = (List **) palloc((levels_needed + 1) * sizeof(List *)); - MemSet(joinitems, 0, (levels_needed + 1) * sizeof(List *)); + joinitems = (List **) palloc0((levels_needed + 1) * sizeof(List *)); joinitems[1] = initial_rels; diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 94eb54156c..46d1bb0755 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.141 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.142 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1070,8 +1070,7 @@ gen_cross_product(InhPaths *arginh, int nargs) /* compute the cross product from right to left */ for (;;) { - oneres = (Oid *) palloc(FUNC_MAX_ARGS * sizeof(Oid)); - MemSet(oneres, 0, FUNC_MAX_ARGS * sizeof(Oid)); + oneres = (Oid *) palloc0(FUNC_MAX_ARGS * sizeof(Oid)); for (i = nargs - 1; i >= 0 && cur[i] > arginh[i].nsupers; i--) continue; diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 31a7abbe26..f0bb1856ab 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.71 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.72 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,8 +40,7 @@ make_parsestate(ParseState *parentParseState) { ParseState *pstate; - pstate = palloc(sizeof(ParseState)); - MemSet(pstate, 0, sizeof(ParseState)); + pstate = palloc0(sizeof(ParseState)); pstate->parentParseState = parentParseState; pstate->p_last_resno = 1; diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 7fa02fedd5..7f36802007 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.292 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.293 2002/11/13 00:39:47 momjian Exp $ * * NOTES * @@ -1092,10 +1092,8 @@ ProcessStartupPacket(Port *port, bool SSLdone) if (len < sizeof(ProtocolVersion) || len > sizeof(StartupPacket)) elog(FATAL, "invalid length of startup packet"); - buf = palloc(sizeof(StartupPacket)); - /* Ensure we see zeroes for any bytes not sent */ - MemSet(buf, 0, sizeof(StartupPacket)); + buf = palloc0(sizeof(StartupPacket)); if (pq_getbytes(buf, len) == EOF) { diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index 120df24109..c97e242937 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.82 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.83 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -248,8 +248,7 @@ makeacl(int n) if (n < 0) elog(ERROR, "makeacl: invalid size: %d", n); size = ACL_N_SIZE(n); - new_acl = (Acl *) palloc(size); - MemSet((char *) new_acl, 0, size); + new_acl = (Acl *) palloc0(size); new_acl->size = size; new_acl->ndim = 1; new_acl->flags = 0; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index df75d660f5..c791877bb5 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.84 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.85 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -235,8 +235,7 @@ array_in(PG_FUNCTION_ARGS) if (nitems == 0) { /* Return empty array */ - retval = (ArrayType *) palloc(sizeof(ArrayType)); - MemSet(retval, 0, sizeof(ArrayType)); + retval = (ArrayType *) palloc0(sizeof(ArrayType)); retval->size = sizeof(ArrayType); retval->elemtype = element_type; PG_RETURN_ARRAYTYPE_P(retval); @@ -249,8 +248,7 @@ array_in(PG_FUNCTION_ARGS) typmod, typdelim, typlen, typbyval, typalign, &nbytes); nbytes += ARR_OVERHEAD(ndim); - retval = (ArrayType *) palloc(nbytes); - MemSet(retval, 0, nbytes); + retval = (ArrayType *) palloc0(nbytes); retval->size = nbytes; retval->ndim = ndim; retval->elemtype = element_type; @@ -397,8 +395,7 @@ ReadArrayStr(char *arrayStr, prod[MAXDIM]; mda_get_prod(ndim, dim, prod); - values = (Datum *) palloc(nitems * sizeof(Datum)); - MemSet(values, 0, nitems * sizeof(Datum)); + values = (Datum *) palloc0(nitems * sizeof(Datum)); MemSet(indx, 0, sizeof(indx)); /* read array enclosed within {} */ @@ -514,10 +511,7 @@ ReadArrayStr(char *arrayStr, if (!typbyval) for (i = 0; i < nitems; i++) if (values[i] == (Datum) 0) - { - values[i] = PointerGetDatum(palloc(typlen)); - MemSet(DatumGetPointer(values[i]), 0, typlen); - } + values[i] = PointerGetDatum(palloc0(typlen)); } else { @@ -1593,8 +1587,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType) /* Allocate and initialize the result array */ nbytes += ARR_OVERHEAD(ndim); - result = (ArrayType *) palloc(nbytes); - MemSet(result, 0, nbytes); + result = (ArrayType *) palloc0(nbytes); result->size = nbytes; result->ndim = ndim; diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index a0ddd37723..cf48c51d75 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.70 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.71 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -3130,9 +3130,8 @@ poly_in(PG_FUNCTION_ARGS) elog(ERROR, "Bad polygon external representation '%s'", str); size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; - poly = (POLYGON *) palloc(size); + poly = (POLYGON *) palloc0(size); /* zero any holes */ - MemSet((char *) poly, 0, size); /* zero any holes */ poly->size = size; poly->npts = npts; @@ -4452,9 +4451,7 @@ circle_poly(PG_FUNCTION_ARGS) if (base_size / npts != sizeof(poly->p[0]) || size <= base_size) elog(ERROR, "too many points requested"); - poly = (POLYGON *) palloc(size); - - MemSet(poly, 0, size); /* zero any holes */ + poly = (POLYGON *) palloc0(size); /* zero any holes */ poly->size = size; poly->npts = npts; diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 0985c6a459..5757a3c1fa 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -3,7 +3,7 @@ * is for IP V4 CIDR notation, but prepared for V6: just * add the necessary bits where the comments indicate. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.37 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.38 2002/11/13 00:39:47 momjian Exp $ * * Jon Postel RIP 16 Oct 1998 */ @@ -51,9 +51,8 @@ network_in(char *src, int type) int bits; inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits in a CIDR value are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); /* First, try for an IP V4 address: */ ip_family(dst) = AF_INET; @@ -494,9 +493,8 @@ network_broadcast(PG_FUNCTION_ARGS) inet *ip = PG_GETARG_INET_P(0); inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); if (ip_family(ip) == AF_INET) { @@ -534,9 +532,8 @@ network_network(PG_FUNCTION_ARGS) inet *ip = PG_GETARG_INET_P(0); inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); if (ip_family(ip) == AF_INET) { @@ -574,9 +571,8 @@ network_netmask(PG_FUNCTION_ARGS) inet *ip = PG_GETARG_INET_P(0); inet *dst; - dst = (inet *) palloc(VARHDRSZ + sizeof(inet_struct)); /* make sure any unused bits are zeroed */ - MemSet(dst, 0, VARHDRSZ + sizeof(inet_struct)); + dst = (inet *) palloc0(VARHDRSZ + sizeof(inet_struct)); if (ip_family(ip) == AF_INET) { diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 69b8e226be..bad7128863 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.28 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.29 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -107,9 +107,8 @@ bit_in(PG_FUNCTION_ARGS) bitlen, atttypmod); len = VARBITTOTALLEN(atttypmod); - result = (VarBit *) palloc(len); /* set to 0 so that *r is always initialised and string is zero-padded */ - MemSet(result, 0, len); + result = (VarBit *) palloc0(len); VARATT_SIZEP(result) = len; VARBITLEN(result) = atttypmod; @@ -232,9 +231,8 @@ bit(PG_FUNCTION_ARGS) VARBITLEN(arg), len); rlen = VARBITTOTALLEN(len); - result = (VarBit *) palloc(rlen); /* set to 0 so that string is zero-padded */ - MemSet(result, 0, rlen); + result = (VarBit *) palloc0(rlen); VARATT_SIZEP(result) = rlen; VARBITLEN(result) = len; @@ -316,9 +314,8 @@ varbit_in(PG_FUNCTION_ARGS) atttypmod); len = VARBITTOTALLEN(bitlen); - result = (VarBit *) palloc(len); /* set to 0 so that *r is always initialised and string is zero-padded */ - MemSet(result, 0, len); + result = (VarBit *) palloc0(len); VARATT_SIZEP(result) = len; VARBITLEN(result) = Min(bitlen, atttypmod); diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index ffae38015b..77ddf4a50e 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.101 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.102 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -808,8 +808,7 @@ InitCatCache(int id, * * Note: we assume zeroing initializes the Dllist headers correctly */ - cp = (CatCache *) palloc(sizeof(CatCache) + NCCBUCKETS * sizeof(Dllist)); - MemSet((char *) cp, 0, sizeof(CatCache) + NCCBUCKETS * sizeof(Dllist)); + cp = (CatCache *) palloc0(sizeof(CatCache) + NCCBUCKETS * sizeof(Dllist)); /* * initialize the cache's relation information for the relation diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 11bb211c80..877886ff68 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.179 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.180 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1348,13 +1348,9 @@ formrdesc(const char *relationName, /* * allocate new relation desc - */ - relation = (Relation) palloc(sizeof(RelationData)); - - /* * clear all fields of reldesc */ - MemSet((char *) relation, 0, sizeof(RelationData)); + relation = (Relation) palloc0(sizeof(RelationData)); relation->rd_targblock = InvalidBlockNumber; /* make sure relation is marked as having no open file yet */ @@ -1380,8 +1376,7 @@ formrdesc(const char *relationName, * get us launched. RelationCacheInitializePhase2() will read the * real data from pg_class and replace what we've done here. */ - relation->rd_rel = (Form_pg_class) palloc(CLASS_TUPLE_SIZE); - MemSet(relation->rd_rel, 0, CLASS_TUPLE_SIZE); + relation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); namestrcpy(&relation->rd_rel->relname, relationName); relation->rd_rel->relnamespace = PG_CATALOG_NAMESPACE; @@ -2054,8 +2049,7 @@ RelationBuildLocalRelation(const char *relname, /* * allocate a new relation descriptor and fill in basic state fields. */ - rel = (Relation) palloc(sizeof(RelationData)); - MemSet((char *) rel, 0, sizeof(RelationData)); + rel = (Relation) palloc0(sizeof(RelationData)); rel->rd_targblock = InvalidBlockNumber; @@ -2093,8 +2087,7 @@ RelationBuildLocalRelation(const char *relname, /* * initialize relation tuple form (caller may add/override data later) */ - rel->rd_rel = (Form_pg_class) palloc(CLASS_TUPLE_SIZE); - MemSet((char *) rel->rd_rel, 0, CLASS_TUPLE_SIZE); + rel->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE); namestrcpy(&rel->rd_rel->relname, relname); rel->rd_rel->relnamespace = relnamespace; diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index d27f749151..c31ef8f6c5 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.65 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.66 2002/11/13 00:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1550,9 +1550,8 @@ Int64GetDatum(int64 X) * with zeroes in the unused bits. This is needed so that, for * example, hash join of int8 will behave properly. */ - int64 *retval = (int64 *) palloc(Max(sizeof(int64), 8)); + int64 *retval = (int64 *) palloc0(Max(sizeof(int64), 8)); - MemSet(retval, 0, Max(sizeof(int64), 8)); *retval = X; return PointerGetDatum(retval); #endif /* INT64_IS_BUSTED */ diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 971a74768b..f8fc25808f 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -78,7 +78,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.31 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.32 2002/11/13 00:39:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -414,9 +414,7 @@ tuplesort_begin_common(bool randomAccess) { Tuplesortstate *state; - state = (Tuplesortstate *) palloc(sizeof(Tuplesortstate)); - - MemSet((char *) state, 0, sizeof(Tuplesortstate)); + state = (Tuplesortstate *) palloc0(sizeof(Tuplesortstate)); state->status = TSS_INITIAL; state->randomAccess = randomAccess; @@ -459,11 +457,9 @@ tuplesort_begin_heap(TupleDesc tupDesc, state->tupDesc = tupDesc; state->nKeys = nkeys; - state->scanKeys = (ScanKey) palloc(nkeys * sizeof(ScanKeyData)); - MemSet(state->scanKeys, 0, nkeys * sizeof(ScanKeyData)); + state->scanKeys = (ScanKey) palloc0(nkeys * sizeof(ScanKeyData)); state->sortFnKinds = (SortFunctionKind *) - palloc(nkeys * sizeof(SortFunctionKind)); - MemSet(state->sortFnKinds, 0, nkeys * sizeof(SortFunctionKind)); + palloc0(nkeys * sizeof(SortFunctionKind)); for (i = 0; i < nkeys; i++) { diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index 80181a6818..37e073b358 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -26,7 +26,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.9 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplestore.c,v 1.10 2002/11/13 00:39:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -197,9 +197,7 @@ tuplestore_begin_common(bool randomAccess, int maxKBytes) { Tuplestorestate *state; - state = (Tuplestorestate *) palloc(sizeof(Tuplestorestate)); - - MemSet((char *) state, 0, sizeof(Tuplestorestate)); + state = (Tuplestorestate *) palloc0(sizeof(Tuplestorestate)); state->status = TSS_INITIAL; state->randomAccess = randomAccess; diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 1ebf494f97..0f99d85462 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.68 2002/11/11 03:02:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.69 2002/11/13 00:39:48 momjian Exp $ * * 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) exec_prepare_plan(estate, expr); - + rc = exec_run_select(estate, expr, 0, NULL); if (rc != SPI_OK_SELECT) elog(ERROR, "query \"%s\" didn't return data", expr->query); @@ -1627,9 +1627,8 @@ exec_stmt_return_next(PLpgSQL_execstate * estate, if (natts != stmt->row->nfields) elog(ERROR, "Wrong record type supplied in RETURN NEXT"); - dvalues = (Datum *) palloc(natts * sizeof(Datum)); + dvalues = (Datum *) palloc0(natts * sizeof(Datum)); nulls = (char *) palloc(natts * sizeof(char)); - MemSet(dvalues, 0, natts * sizeof(Datum)); MemSet(nulls, 'n', natts); for (i = 0; i < natts; i++) diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index 99e6085bf2..db887c304d 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.53 2002/11/11 03:02:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.54 2002/11/13 00:39:48 momjian Exp $ */ #include "postgres.h" @@ -300,12 +300,11 @@ reverse_name(char *string) int len; char *new_string; - if (!(new_string = palloc(NAMEDATALEN))) + if (!(new_string = palloc0(NAMEDATALEN))) { fprintf(stderr, "reverse_name: palloc failed\n"); return NULL; } - MemSet(new_string, 0, NAMEDATALEN); for (i = 0; i < NAMEDATALEN && string[i]; ++i) ; if (i == NAMEDATALEN || !string[i]) |