diff options
| author | Michael Paquier | 2025-12-09 22:36:46 +0000 |
|---|---|---|
| committer | Michael Paquier | 2025-12-09 22:36:46 +0000 |
| commit | 1b105f9472bdb9a68f709778afafb494997267bd (patch) | |
| tree | 205727d30b0dd4f3060bc1f49a9efa724ee3ff80 /src/backend/access/index/genam.c | |
| parent | c507ba55f5bfae900baa94f1c657e1d99da5c6dc (diff) | |
Use palloc_object() and palloc_array() in backend code
The idea is to encourage more the use of these new routines across the
tree, as these offer stronger type safety guarantees than palloc().
This batch of changes includes most of the trivial changes suggested by
the author for src/backend/.
A total of 334 files are updated here. Among these files, 48 of them
have their build change slightly; these are caused by line number
changes as the new allocation formulas are simpler, shaving around 100
lines of code in total.
Similar work has been done in 0c3c5c3b06a3 and 31d3847a37be.
Author: David Geier <geidav.pg@gmail.com>
Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com
Diffstat (limited to 'src/backend/access/index/genam.c')
| -rw-r--r-- | src/backend/access/index/genam.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index c96917085c2..707c25289cd 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -81,7 +81,7 @@ RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys) { IndexScanDesc scan; - scan = (IndexScanDesc) palloc(sizeof(IndexScanDescData)); + scan = palloc_object(IndexScanDescData); scan->heapRelation = NULL; /* may be set later */ scan->xs_heapfetch = NULL; @@ -94,11 +94,11 @@ RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys) * We allocate key workspace here, but it won't get filled until amrescan. */ if (nkeys > 0) - scan->keyData = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys); + scan->keyData = palloc_array(ScanKeyData, nkeys); else scan->keyData = NULL; if (norderbys > 0) - scan->orderByData = (ScanKey) palloc(sizeof(ScanKeyData) * norderbys); + scan->orderByData = palloc_array(ScanKeyData, norderbys); else scan->orderByData = NULL; @@ -310,8 +310,8 @@ index_compute_xid_horizon_for_tuples(Relation irel, delstate.bottomup = false; delstate.bottomupfreespace = 0; delstate.ndeltids = 0; - delstate.deltids = palloc(nitems * sizeof(TM_IndexDelete)); - delstate.status = palloc(nitems * sizeof(TM_IndexStatus)); + delstate.deltids = palloc_array(TM_IndexDelete, nitems); + delstate.status = palloc_array(TM_IndexStatus, nitems); /* identify what the index tuples about to be deleted point to */ for (int i = 0; i < nitems; i++) @@ -401,7 +401,7 @@ systable_beginscan(Relation heapRelation, else irel = NULL; - sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData)); + sysscan = palloc_object(SysScanDescData); sysscan->heap_rel = heapRelation; sysscan->irel = irel; @@ -667,7 +667,7 @@ systable_beginscan_ordered(Relation heapRelation, elog(WARNING, "using index \"%s\" despite IgnoreSystemIndexes", RelationGetRelationName(indexRelation)); - sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData)); + sysscan = palloc_object(SysScanDescData); sysscan->heap_rel = heapRelation; sysscan->irel = indexRelation; |
