summaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistsplit.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/access/gist/gistsplit.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/access/gist/gistsplit.c')
-rw-r--r--src/backend/access/gist/gistsplit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/access/gist/gistsplit.c b/src/backend/access/gist/gistsplit.c
index 49838ceb07b..21fea505d9c 100644
--- a/src/backend/access/gist/gistsplit.c
+++ b/src/backend/access/gist/gistsplit.c
@@ -51,7 +51,7 @@ gistunionsubkeyvec(GISTSTATE *giststate, IndexTuple *itvec,
int i,
cleanedLen = 0;
- cleanedItVec = (IndexTuple *) palloc(sizeof(IndexTuple) * gsvp->len);
+ cleanedItVec = palloc_array(IndexTuple, gsvp->len);
for (i = 0; i < gsvp->len; i++)
{
@@ -501,7 +501,7 @@ gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVec
* Locate don't-care tuples, if any. If there are none, the split is
* optimal, so just fall out and return false.
*/
- v->spl_dontcare = (bool *) palloc0(sizeof(bool) * (entryvec->n + 1));
+ v->spl_dontcare = palloc0_array(bool, entryvec->n + 1);
NumDontCare = findDontCares(r, giststate, entryvec->vector, v, attno);
@@ -738,9 +738,9 @@ gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len,
* call will overwrite that with its own result.
*/
backupSplit = v->splitVector;
- backupSplit.spl_left = (OffsetNumber *) palloc(sizeof(OffsetNumber) * len);
+ backupSplit.spl_left = palloc_array(OffsetNumber, len);
memcpy(backupSplit.spl_left, v->splitVector.spl_left, sizeof(OffsetNumber) * v->splitVector.spl_nleft);
- backupSplit.spl_right = (OffsetNumber *) palloc(sizeof(OffsetNumber) * len);
+ backupSplit.spl_right = palloc_array(OffsetNumber, len);
memcpy(backupSplit.spl_right, v->splitVector.spl_right, sizeof(OffsetNumber) * v->splitVector.spl_nright);
/* Recursively decide how to split the don't-care tuples */