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/storage/lmgr/lwlock.c | |
parent | 30d98e14a88930c6d9658525fd5e6722e70a02e6 (diff) | |
download | postgresql-b4b7ce8061d34cea2b4915c41403b2a74d5fde0e.tar.gz |
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/storage/lmgr/lwlock.c')
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 0fc0cf6ebb..532cd67f4e 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -668,13 +668,8 @@ LWLockRegisterTranche(int tranche_id, const char *tranche_name) MemoryContextAllocZero(TopMemoryContext, newalloc * sizeof(char *)); else - { - LWLockTrancheNames = (const char **) - repalloc(LWLockTrancheNames, newalloc * sizeof(char *)); - memset(LWLockTrancheNames + LWLockTrancheNamesAllocated, - 0, - (newalloc - LWLockTrancheNamesAllocated) * sizeof(char *)); - } + LWLockTrancheNames = + repalloc0_array(LWLockTrancheNames, const char *, LWLockTrancheNamesAllocated, newalloc); LWLockTrancheNamesAllocated = newalloc; } |