mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user