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/utils/adt/ruleutils.c | |
parent | 30d98e14a88930c6d9658525fd5e6722e70a02e6 (diff) | |
download | postgresql-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/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 70d723e80ca..c5a49d0be34 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -4855,14 +4855,9 @@ expand_colnames_array_to(deparse_columns *colinfo, int n) if (n > colinfo->num_cols) { if (colinfo->colnames == NULL) - colinfo->colnames = (char **) palloc0(n * sizeof(char *)); + colinfo->colnames = palloc0_array(char *, n); else - { - colinfo->colnames = (char **) repalloc(colinfo->colnames, - n * sizeof(char *)); - memset(colinfo->colnames + colinfo->num_cols, 0, - (n - colinfo->num_cols) * sizeof(char *)); - } + colinfo->colnames = repalloc0_array(colinfo->colnames, char *, colinfo->num_cols, n); colinfo->num_cols = n; } } |