aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/palloc.h
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-11-12 20:31:27 +0100
committerPeter Eisentraut <peter@eisentraut.org>2022-11-12 20:34:44 +0100
commitb4b7ce8061d34cea2b4915c41403b2a74d5fde0e (patch)
tree127e3012c81c377513fc234f0b8af27f16cf0c31 /src/include/utils/palloc.h
parent30d98e14a88930c6d9658525fd5e6722e70a02e6 (diff)
downloadpostgresql-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/include/utils/palloc.h')
-rw-r--r--src/include/utils/palloc.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index 8eee0e29385..72d4e70dc64 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -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