summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/indxpath.c
diff options
context:
space:
mode:
authorMichael Paquier2025-12-09 22:36:46 +0000
committerMichael Paquier2025-12-09 22:36:46 +0000
commit1b105f9472bdb9a68f709778afafb494997267bd (patch)
tree205727d30b0dd4f3060bc1f49a9efa724ee3ff80 /src/backend/optimizer/path/indxpath.c
parentc507ba55f5bfae900baa94f1c657e1d99da5c6dc (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/optimizer/path/indxpath.c')
-rw-r--r--src/backend/optimizer/path/indxpath.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 2654c59c4c6..5d4f81ee77e 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -1291,7 +1291,7 @@ group_similar_or_args(PlannerInfo *root, RelOptInfo *rel, RestrictInfo *rinfo)
* which will be used to sort these arguments at the next step.
*/
i = -1;
- matches = (OrArgIndexMatch *) palloc(sizeof(OrArgIndexMatch) * n);
+ matches = palloc_array(OrArgIndexMatch, n);
foreach(lc, orargs)
{
Node *arg = lfirst(lc);
@@ -1853,8 +1853,7 @@ choose_bitmap_and(PlannerInfo *root, RelOptInfo *rel, List *paths)
* same set of clauses; keep only the cheapest-to-scan of any such groups.
* The surviving paths are put into an array for qsort'ing.
*/
- pathinfoarray = (PathClauseUsage **)
- palloc(npaths * sizeof(PathClauseUsage *));
+ pathinfoarray = palloc_array(PathClauseUsage *, npaths);
clauselist = NIL;
npaths = 0;
foreach(l, paths)
@@ -2090,7 +2089,7 @@ classify_index_clause_usage(Path *path, List **clauselist)
Bitmapset *clauseids;
ListCell *lc;
- result = (PathClauseUsage *) palloc(sizeof(PathClauseUsage));
+ result = palloc_object(PathClauseUsage);
result->path = path;
/* Recursively find the quals and preds used by the path */