Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fee961

Browse files
committed
Merge palloc()/MemSet(0) calls into a single palloc0() call.
1 parent78822b3 commit8fee961

File tree

37 files changed

+107
-210
lines changed

37 files changed

+107
-210
lines changed

‎contrib/dblink/dblink.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,7 @@ init_dblink_results(MemoryContext fn_mcxt)
14421442

14431443
oldcontext=MemoryContextSwitchTo(fn_mcxt);
14441444

1445-
retval= (dblink_results*)palloc(sizeof(dblink_results));
1446-
MemSet(retval,0,sizeof(dblink_results));
1445+
retval= (dblink_results*)palloc0(sizeof(dblink_results));
14471446

14481447
retval->tup_num=-1;
14491448
retval->res_id_index=-1;

‎contrib/intarray/_int.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,8 @@ new_intArrayType(int num)
916916
ArrayType*r;
917917
intnbytes=ARR_OVERHEAD(NDIM)+sizeof(int)*num;
918918

919-
r= (ArrayType*)palloc(nbytes);
919+
r= (ArrayType*)palloc0(nbytes);
920920

921-
MemSet(r,0,nbytes);
922-
923921
ARR_SIZE(r)=nbytes;
924922
ARR_NDIM(r)=NDIM;
925923
ARR_ELEMTYPE(r)=INT4OID;

‎src/backend/access/common/indextuple.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.60 2002/09/04 20:31:08 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.61 2002/11/10 07:25:13 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -121,9 +121,8 @@ index_formtuple(TupleDesc tupleDescriptor,
121121
#endif
122122
size=MAXALIGN(size);/* be conservative */
123123

124-
tp= (char*)palloc(size);
124+
tp= (char*)palloc0(size);
125125
tuple= (IndexTuple)tp;
126-
MemSet(tp,0,size);
127126

128127
DataFill((char*)tp+hoff,
129128
tupleDescriptor,

‎src/backend/access/common/tupdesc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.91 2002/09/28 20:00:18 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.92 2002/11/10 07:25:13 momjian Exp $
1212
*
1313
* NOTES
1414
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -60,8 +60,7 @@ CreateTemplateTupleDesc(int natts, bool hasoid)
6060
{
6161
uint32size=natts*sizeof(Form_pg_attribute);
6262

63-
desc->attrs= (Form_pg_attribute*)palloc(size);
64-
MemSet(desc->attrs,0,size);
63+
desc->attrs= (Form_pg_attribute*)palloc0(size);
6564
}
6665
else
6766
desc->attrs=NULL;

‎src/backend/access/gist/gist.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.96 2002/09/04 20:31:09 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.97 2002/11/10 07:25:13 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1316,10 +1316,8 @@ gistSplit(Relation r,
13161316
*/
13171317
if (r->rd_att->natts>1)
13181318
{
1319-
v.spl_idgrp= (int*)palloc(sizeof(int)* (*len+1));
1320-
MemSet((void*)v.spl_idgrp,0,sizeof(int)* (*len+1));
1321-
v.spl_grpflag= (char*)palloc(sizeof(char)* (*len+1));
1322-
MemSet((void*)v.spl_grpflag,0,sizeof(char)* (*len+1));
1319+
v.spl_idgrp= (int*)palloc0(sizeof(int)* (*len+1));
1320+
v.spl_grpflag= (char*)palloc0(sizeof(char)* (*len+1));
13231321
v.spl_ngrp= (int*)palloc(sizeof(int)* (*len+1));
13241322

13251323
MaxGrpId=gistfindgroup(giststate, (GISTENTRY*)VARDATA(entryvec),&v);

‎src/backend/access/nbtree/nbtsort.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* Portions Copyright (c) 1994, Regents of the University of California
3636
*
3737
* IDENTIFICATION
38-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.66 2002/08/06 19:41:23 tgl Exp $
38+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.67 2002/11/10 07:25:13 momjian Exp $
3939
*
4040
*-------------------------------------------------------------------------
4141
*/
@@ -111,9 +111,7 @@ static void _bt_load(Relation index, BTSpool *btspool, BTSpool *btspool2);
111111
BTSpool*
112112
_bt_spoolinit(Relationindex,boolisunique)
113113
{
114-
BTSpool*btspool= (BTSpool*)palloc(sizeof(BTSpool));
115-
116-
MemSet((char*)btspool,0,sizeof(BTSpool));
114+
BTSpool*btspool= (BTSpool*)palloc0(sizeof(BTSpool));
117115

118116
btspool->index=index;
119117
btspool->isunique=isunique;
@@ -207,9 +205,7 @@ _bt_blnewpage(Relation index, Buffer *buf, Page *page, int flags)
207205
staticBTPageState*
208206
_bt_pagestate(Relationindex,intflags,intlevel)
209207
{
210-
BTPageState*state= (BTPageState*)palloc(sizeof(BTPageState));
211-
212-
MemSet((char*)state,0,sizeof(BTPageState));
208+
BTPageState*state= (BTPageState*)palloc0(sizeof(BTPageState));
213209

214210
/* create initial page */
215211
_bt_blnewpage(index,&(state->btps_buf),&(state->btps_page),flags);

‎src/backend/access/rtree/rtproc.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.33 2002/06/20 20:29:25 momjian Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.34 2002/11/10 07:25:13 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -103,9 +103,7 @@ rt_poly_union(PG_FUNCTION_ARGS)
103103
POLYGON*b=PG_GETARG_POLYGON_P(1);
104104
POLYGON*p;
105105

106-
p= (POLYGON*)palloc(sizeof(POLYGON));
107-
108-
MemSet((char*)p,0,sizeof(POLYGON));/* zero any holes */
106+
p= (POLYGON*)palloc0(sizeof(POLYGON));/* zero any holes */
109107
p->size=sizeof(POLYGON);
110108
p->npts=0;
111109
p->boundbox.high.x=Max(a->boundbox.high.x,b->boundbox.high.x);
@@ -127,9 +125,7 @@ rt_poly_inter(PG_FUNCTION_ARGS)
127125
POLYGON*b=PG_GETARG_POLYGON_P(1);
128126
POLYGON*p;
129127

130-
p= (POLYGON*)palloc(sizeof(POLYGON));
131-
132-
MemSet((char*)p,0,sizeof(POLYGON));/* zero any holes */
128+
p= (POLYGON*)palloc0(sizeof(POLYGON));/* zero any holes */
133129
p->size=sizeof(POLYGON);
134130
p->npts=0;
135131
p->boundbox.high.x=Min(a->boundbox.high.x,b->boundbox.high.x);

‎src/backend/catalog/index.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.202 2002/10/21 22:06:19 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.203 2002/11/10 07:25:13 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -112,8 +112,7 @@ BuildFuncTupleDesc(Oid funcOid,
112112
* Allocate and zero a tuple descriptor for a one-column tuple.
113113
*/
114114
funcTupDesc=CreateTemplateTupleDesc(1, false);
115-
funcTupDesc->attrs[0]= (Form_pg_attribute)palloc(ATTRIBUTE_TUPLE_SIZE);
116-
MemSet(funcTupDesc->attrs[0],0,ATTRIBUTE_TUPLE_SIZE);
115+
funcTupDesc->attrs[0]= (Form_pg_attribute)palloc0(ATTRIBUTE_TUPLE_SIZE);
117116

118117
/*
119118
* Lookup the function to get its name and return type.

‎src/backend/commands/analyze.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.47 2002/09/23 20:43:40 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.48 2002/11/10 07:25:13 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -423,8 +423,7 @@ examine_attribute(Relation onerel, int attnum)
423423
* If we have "=" then we're at least able to do the minimal
424424
* algorithm, so start filling in a VacAttrStats struct.
425425
*/
426-
stats= (VacAttrStats*)palloc(sizeof(VacAttrStats));
427-
MemSet(stats,0,sizeof(VacAttrStats));
426+
stats= (VacAttrStats*)palloc0(sizeof(VacAttrStats));
428427
stats->attnum=attnum;
429428
stats->attr= (Form_pg_attribute)palloc(ATTRIBUTE_TUPLE_SIZE);
430429
memcpy(stats->attr,attr,ATTRIBUTE_TUPLE_SIZE);

‎src/backend/commands/copy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.177 2002/10/19 00:25:36 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.178 2002/11/10 07:25:13 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -804,9 +804,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
804804
elements= (Oid*)palloc(num_phys_attrs*sizeof(Oid));
805805
defmap= (int*)palloc(num_phys_attrs*sizeof(int));
806806
defexprs= (Node**)palloc(num_phys_attrs*sizeof(Node*));
807-
constraintexprs= (Node**)palloc(num_phys_attrs*sizeof(Node*));
807+
constraintexprs= (Node**)palloc0(num_phys_attrs*sizeof(Node*));
808808
constraintconsts= (Const**)palloc(num_phys_attrs*sizeof(Const*));
809-
MemSet(constraintexprs,0,num_phys_attrs*sizeof(Node*));
810809

811810
for (i=0;i<num_phys_attrs;i++)
812811
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp