From b4b7ce8061d34cea2b4915c41403b2a74d5fde0e Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 12 Nov 2022 20:31:27 +0100 Subject: Add repalloc0 and repalloc0_array These zero out the space added by repalloc. This is a common pattern that is quite hairy to code by hand. Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/b66dfc89-9365-cb57-4e1f-b7d31813eeec@enterprisedb.com --- src/backend/executor/nodeHash.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/backend/executor/nodeHash.c') diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 6622b202c22..2e6cce4802e 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -940,12 +940,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable) else { /* enlarge arrays and zero out added entries */ - hashtable->innerBatchFile = repalloc_array(hashtable->innerBatchFile, BufFile *, nbatch); - hashtable->outerBatchFile = repalloc_array(hashtable->outerBatchFile, BufFile *, nbatch); - MemSet(hashtable->innerBatchFile + oldnbatch, 0, - (nbatch - oldnbatch) * sizeof(BufFile *)); - MemSet(hashtable->outerBatchFile + oldnbatch, 0, - (nbatch - oldnbatch) * sizeof(BufFile *)); + hashtable->innerBatchFile = repalloc0_array(hashtable->innerBatchFile, BufFile *, oldnbatch, nbatch); + hashtable->outerBatchFile = repalloc0_array(hashtable->outerBatchFile, BufFile *, oldnbatch, nbatch); } MemoryContextSwitchTo(oldcxt); -- cgit v1.2.3