diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-11-12 20:31:27 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-11-12 20:34:44 +0100 |
commit | b4b7ce8061d34cea2b4915c41403b2a74d5fde0e (patch) | |
tree | 127e3012c81c377513fc234f0b8af27f16cf0c31 /src/backend/executor/nodeHash.c | |
parent | 30d98e14a88930c6d9658525fd5e6722e70a02e6 (diff) | |
download | postgresql-b4b7ce8061d34cea2b4915c41403b2a74d5fde0e.tar.gz postgresql-b4b7ce8061d34cea2b4915c41403b2a74d5fde0e.zip |
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 <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/b66dfc89-9365-cb57-4e1f-b7d31813eeec@enterprisedb.com
Diffstat (limited to 'src/backend/executor/nodeHash.c')
-rw-r--r-- | src/backend/executor/nodeHash.c | 8 |
1 files changed, 2 insertions, 6 deletions
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); |