mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +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:
@@ -80,6 +80,7 @@ extern void *palloc_extended(Size size, int flags);
|
||||
extern pg_nodiscard void *repalloc(void *pointer, Size size);
|
||||
extern pg_nodiscard void *repalloc_extended(void *pointer,
|
||||
Size size, int flags);
|
||||
extern pg_nodiscard void *repalloc0(void *pointer, Size oldsize, Size size);
|
||||
extern void pfree(void *pointer);
|
||||
|
||||
/*
|
||||
@@ -103,6 +104,7 @@ extern void pfree(void *pointer);
|
||||
* objects of type "type"
|
||||
*/
|
||||
#define repalloc_array(pointer, type, count) ((type *) repalloc(pointer, sizeof(type) * (count)))
|
||||
#define repalloc0_array(pointer, type, oldcount, count) ((type *) repalloc0(pointer, sizeof(type) * (oldcount), sizeof(type) * (count)))
|
||||
|
||||
/*
|
||||
* The result of palloc() is always word-aligned, so we can skip testing
|
||||
|
||||
Reference in New Issue
Block a user