@@ -229,10 +229,10 @@ CheckIndexCompatible(Oid oldId,
229
229
*/
230
230
indexInfo = makeIndexInfo (numberOfAttributes , numberOfAttributes ,
231
231
accessMethodId , NIL , NIL , false, false, false, false);
232
- typeObjectId = (Oid * ) palloc ( numberOfAttributes * sizeof ( Oid ) );
233
- collationObjectId = (Oid * ) palloc ( numberOfAttributes * sizeof ( Oid ) );
234
- classObjectId = (Oid * ) palloc ( numberOfAttributes * sizeof ( Oid ) );
235
- coloptions = (int16 * ) palloc ( numberOfAttributes * sizeof ( int16 ) );
232
+ typeObjectId = palloc_array (Oid , numberOfAttributes );
233
+ collationObjectId = palloc_array (Oid , numberOfAttributes );
234
+ classObjectId = palloc_array (Oid , numberOfAttributes );
235
+ coloptions = palloc_array (int16 , numberOfAttributes );
236
236
ComputeIndexAttrs (indexInfo ,
237
237
typeObjectId , collationObjectId , classObjectId ,
238
238
coloptions , attributeList ,
@@ -895,10 +895,10 @@ DefineIndex(Oid relationId,
895
895
!concurrent ,
896
896
concurrent );
897
897
898
- typeObjectId = (Oid * ) palloc ( numberOfAttributes * sizeof ( Oid ) );
899
- collationObjectId = (Oid * ) palloc ( numberOfAttributes * sizeof ( Oid ) );
900
- classObjectId = (Oid * ) palloc ( numberOfAttributes * sizeof ( Oid ) );
901
- coloptions = (int16 * ) palloc ( numberOfAttributes * sizeof ( int16 ) );
898
+ typeObjectId = palloc_array (Oid , numberOfAttributes );
899
+ collationObjectId = palloc_array (Oid , numberOfAttributes );
900
+ classObjectId = palloc_array (Oid , numberOfAttributes );
901
+ coloptions = palloc_array (int16 , numberOfAttributes );
902
902
ComputeIndexAttrs (indexInfo ,
903
903
typeObjectId , collationObjectId , classObjectId ,
904
904
coloptions , allIndexParams ,
@@ -1210,7 +1210,7 @@ DefineIndex(Oid relationId,
1210
1210
if ((!stmt -> relation || stmt -> relation -> inh ) && partdesc -> nparts > 0 )
1211
1211
{
1212
1212
int nparts = partdesc -> nparts ;
1213
- Oid * part_oids = palloc ( sizeof ( Oid ) * nparts );
1213
+ Oid * part_oids = palloc_array ( Oid , nparts );
1214
1214
bool invalidate_parent = false;
1215
1215
Relation parentIndex ;
1216
1216
TupleDesc parentDesc ;
@@ -1786,9 +1786,9 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
1786
1786
if (exclusionOpNames )
1787
1787
{
1788
1788
Assert (list_length (exclusionOpNames ) == nkeycols );
1789
- indexInfo -> ii_ExclusionOps = (Oid * ) palloc ( sizeof ( Oid ) * nkeycols );
1790
- indexInfo -> ii_ExclusionProcs = (Oid * ) palloc ( sizeof ( Oid ) * nkeycols );
1791
- indexInfo -> ii_ExclusionStrats = (uint16 * ) palloc ( sizeof ( uint16 ) * nkeycols );
1789
+ indexInfo -> ii_ExclusionOps = palloc_array (Oid , nkeycols );
1790
+ indexInfo -> ii_ExclusionProcs = palloc_array (Oid , nkeycols );
1791
+ indexInfo -> ii_ExclusionStrats = palloc_array (uint16 , nkeycols );
1792
1792
nextExclOp = list_head (exclusionOpNames );
1793
1793
}
1794
1794
else
@@ -2112,7 +2112,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
2112
2112
2113
2113
if (!indexInfo -> ii_OpclassOptions )
2114
2114
indexInfo -> ii_OpclassOptions =
2115
- palloc0 ( sizeof ( Datum ) * indexInfo -> ii_NumIndexAttrs );
2115
+ palloc0_array ( Datum , indexInfo -> ii_NumIndexAttrs );
2116
2116
2117
2117
indexInfo -> ii_OpclassOptions [attn ] =
2118
2118
transformRelOptions ((Datum ) 0 , attribute -> opclassopts ,
@@ -3459,7 +3459,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
3459
3459
/* Save the list of relation OIDs in private context */
3460
3460
oldcontext = MemoryContextSwitchTo (private_context );
3461
3461
3462
- idx = palloc ( sizeof ( ReindexIndexInfo ) );
3462
+ idx = palloc_object ( ReindexIndexInfo );
3463
3463
idx -> indexId = cellOid ;
3464
3464
/* other fields set later */
3465
3465
@@ -3508,7 +3508,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
3508
3508
*/
3509
3509
oldcontext = MemoryContextSwitchTo (private_context );
3510
3510
3511
- idx = palloc ( sizeof ( ReindexIndexInfo ) );
3511
+ idx = palloc_object ( ReindexIndexInfo );
3512
3512
idx -> indexId = cellOid ;
3513
3513
indexIds = lappend (indexIds , idx );
3514
3514
/* other fields set later */
@@ -3589,7 +3589,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
3589
3589
* Save the list of relation OIDs in private context. Note
3590
3590
* that invalid indexes are allowed here.
3591
3591
*/
3592
- idx = palloc ( sizeof ( ReindexIndexInfo ) );
3592
+ idx = palloc_object ( ReindexIndexInfo );
3593
3593
idx -> indexId = relationOid ;
3594
3594
indexIds = lappend (indexIds , idx );
3595
3595
/* other fields set later */
@@ -3734,7 +3734,7 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
3734
3734
*/
3735
3735
oldcontext = MemoryContextSwitchTo (private_context );
3736
3736
3737
- newidx = palloc ( sizeof ( ReindexIndexInfo ) );
3737
+ newidx = palloc_object ( ReindexIndexInfo );
3738
3738
newidx -> indexId = newIndexId ;
3739
3739
newidx -> safe = idx -> safe ;
3740
3740
newidx -> tableId = idx -> tableId ;
@@ -3748,10 +3748,10 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
3748
3748
* avoid multiple locks taken on the same relation, instead we rely on
3749
3749
* parentRelationIds built earlier.
3750
3750
*/
3751
- lockrelid = palloc ( sizeof ( * lockrelid ) );
3751
+ lockrelid = palloc_object ( LockRelId );
3752
3752
* lockrelid = indexRel -> rd_lockInfo .lockRelId ;
3753
3753
relationLocks = lappend (relationLocks , lockrelid );
3754
- lockrelid = palloc ( sizeof ( * lockrelid ) );
3754
+ lockrelid = palloc_object ( LockRelId );
3755
3755
* lockrelid = newIndexRel -> rd_lockInfo .lockRelId ;
3756
3756
relationLocks = lappend (relationLocks , lockrelid );
3757
3757
@@ -3783,11 +3783,11 @@ ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
3783
3783
oldcontext = MemoryContextSwitchTo (private_context );
3784
3784
3785
3785
/* Add lockrelid of heap relation to the list of locked relations */
3786
- lockrelid = palloc ( sizeof ( * lockrelid ) );
3786
+ lockrelid = palloc_object ( LockRelId );
3787
3787
* lockrelid = heapRelation -> rd_lockInfo .lockRelId ;
3788
3788
relationLocks = lappend (relationLocks , lockrelid );
3789
3789
3790
- heaplocktag = (LOCKTAG * ) palloc ( sizeof ( LOCKTAG ) );
3790
+ heaplocktag = palloc_object (LOCKTAG );
3791
3791
3792
3792
/* Save the LOCKTAG for this parent relation for the wait phase */
3793
3793
SET_LOCKTAG_RELATION (* heaplocktag , lockrelid -> dbId , lockrelid -> relId );
0 commit comments