diff options
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/brin/brin.c | 14 | ||||
-rw-r--r-- | src/backend/access/gin/ginfast.c | 17 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index 69f21abfb59..dcf2d2c4b50 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -329,7 +329,7 @@ brinbeginscan(Relation r, int nkeys, int norderbys) scan = RelationGetIndexScan(r, nkeys, norderbys); - opaque = (BrinOpaque *) palloc(sizeof(BrinOpaque)); + opaque = palloc_object(BrinOpaque); opaque->bo_rmAccess = brinRevmapInitialize(r, &opaque->bo_pagesPerRange, scan->xs_snapshot); opaque->bo_bdesc = brin_build_desc(r); @@ -394,7 +394,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm) * don't look them up here; we do that lazily the first time we see a scan * key reference each of them. We rely on zeroing fn_oid to InvalidOid. */ - consistentFn = palloc0(sizeof(FmgrInfo) * bdesc->bd_tupdesc->natts); + consistentFn = palloc0_array(FmgrInfo, bdesc->bd_tupdesc->natts); /* * Make room for per-attribute lists of scan keys that we'll pass to the @@ -881,7 +881,7 @@ brinbuild(Relation heap, Relation index, IndexInfo *indexInfo) /* * Return statistics */ - result = (IndexBuildResult *) palloc(sizeof(IndexBuildResult)); + result = palloc_object(IndexBuildResult); result->heap_tuples = reltuples; result->index_tuples = idxtuples; @@ -925,7 +925,7 @@ brinbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats, { /* allocate stats if first time through, else re-use existing struct */ if (stats == NULL) - stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult)); + stats = palloc0_object(IndexBulkDeleteResult); return stats; } @@ -944,7 +944,7 @@ brinvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats) return stats; if (!stats) - stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult)); + stats = palloc0_object(IndexBulkDeleteResult); stats->num_pages = RelationGetNumberOfBlocks(info->index); /* rest of stats is initialized by zeroing */ @@ -1204,7 +1204,7 @@ brin_build_desc(Relation rel) * Obtain BrinOpcInfo for each indexed column. While at it, accumulate * the number of columns stored, since the number is opclass-defined. */ - opcinfo = (BrinOpcInfo **) palloc(sizeof(BrinOpcInfo *) * tupdesc->natts); + opcinfo = palloc_array(BrinOpcInfo*, tupdesc->natts); for (keyno = 0; keyno < tupdesc->natts; keyno++) { FmgrInfo *opcInfoFn; @@ -1276,7 +1276,7 @@ initialize_brin_buildstate(Relation idxRel, BrinRevmap *revmap, { BrinBuildState *state; - state = palloc(sizeof(BrinBuildState)); + state = palloc_object(BrinBuildState); state->bs_irel = idxRel; state->bs_numtuples = 0; diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c index 6c677447a95..ab4bb67d4b4 100644 --- a/src/backend/access/gin/ginfast.c +++ b/src/backend/access/gin/ginfast.c @@ -505,7 +505,7 @@ ginHeapTupleFastCollect(GinState *ginstate, * resizing (since palloc likes powers of 2). */ collector->lentuples = pg_nextpower2_32(Max(16, nentries)); - collector->tuples = (IndexTuple *) palloc(sizeof(IndexTuple) * collector->lentuples); + collector->tuples = palloc_array(IndexTuple, collector->lentuples); } else if (collector->lentuples < collector->ntuples + nentries) { @@ -515,8 +515,8 @@ ginHeapTupleFastCollect(GinState *ginstate, * MaxAllocSize/sizeof(IndexTuple), causing an error in repalloc. */ collector->lentuples = pg_nextpower2_32(collector->ntuples + nentries); - collector->tuples = (IndexTuple *) repalloc(collector->tuples, - sizeof(IndexTuple) * collector->lentuples); + collector->tuples = repalloc_array(collector->tuples, + IndexTuple, collector->lentuples); } /* @@ -665,9 +665,8 @@ shiftList(Relation index, Buffer metabuffer, BlockNumber newHead, static void initKeyArray(KeyArray *keys, int32 maxvalues) { - keys->keys = (Datum *) palloc(sizeof(Datum) * maxvalues); - keys->categories = (GinNullCategory *) - palloc(sizeof(GinNullCategory) * maxvalues); + keys->keys = palloc_array(Datum, maxvalues); + keys->categories = palloc_array(GinNullCategory, maxvalues); keys->nvalues = 0; keys->maxvalues = maxvalues; } @@ -679,10 +678,8 @@ addDatum(KeyArray *keys, Datum datum, GinNullCategory category) if (keys->nvalues >= keys->maxvalues) { keys->maxvalues *= 2; - keys->keys = (Datum *) - repalloc(keys->keys, sizeof(Datum) * keys->maxvalues); - keys->categories = (GinNullCategory *) - repalloc(keys->categories, sizeof(GinNullCategory) * keys->maxvalues); + keys->keys = repalloc_array(keys->keys, Datum, keys->maxvalues); + keys->categories = repalloc_array(keys->categories, GinNullCategory, keys->maxvalues); } keys->keys[keys->nvalues] = datum; |