diff options
Diffstat (limited to 'src/backend/utils/mmgr/mcxt.c')
-rw-r--r-- | src/backend/utils/mmgr/mcxt.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index f526ca82c15..57bd6690ca0 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -1396,6 +1396,26 @@ repalloc_extended(void *pointer, Size size, int flags) } /* + * repalloc0 + * Adjust the size of a previously allocated chunk and zero out the added + * space. + */ +void * +repalloc0(void *pointer, Size oldsize, Size size) +{ + void *ret; + + /* catch wrong argument order */ + if (unlikely(oldsize > size)) + elog(ERROR, "invalid repalloc0 call: oldsize %zu, new size %zu", + oldsize, size); + + ret = repalloc(pointer, size); + memset((char *) ret + oldsize, 0, (size - oldsize)); + return ret; +} + +/* * MemoryContextAllocHuge * Allocate (possibly-expansive) space within the specified context. * |