diff options
author | Peter Eisentraut | 2022-09-12 06:31:56 +0000 |
---|---|---|
committer | Peter Eisentraut | 2022-09-12 06:45:03 +0000 |
commit | 5015e1e1b58f81a036e4ad16291ef4b3bb7a596c (patch) | |
tree | 86ee608e961dc830e733c534db089f1e45706414 /src/backend/commands/prepare.c | |
parent | 2016055a92f26d648aba9f66d26cc0bcd1619eff (diff) |
Assorted examples of expanded type-safer palloc/pg_malloc API
This adds some uses of the new palloc/pg_malloc variants here and
there as a demonstration and test. This is kept separate from the
actual API patch, since the latter might be backpatched at some point.
Reviewed-by: Tom Lane <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/[email protected]
Diffstat (limited to 'src/backend/commands/prepare.c')
-rw-r--r-- | src/backend/commands/prepare.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 579825c1593..c4b54d05475 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -98,7 +98,7 @@ PrepareQuery(ParseState *pstate, PrepareStmt *stmt, int i; ListCell *l; - argtypes = (Oid *) palloc(nargs * sizeof(Oid)); + argtypes = palloc_array(Oid, nargs); i = 0; foreach(l, stmt->argtypes) @@ -698,7 +698,7 @@ pg_prepared_statement(PG_FUNCTION_ARGS) { Oid *result_types; - result_types = (Oid *) palloc(result_desc->natts * sizeof(Oid)); + result_types = palloc_array(Oid, result_desc->natts); for (int i = 0; i < result_desc->natts; i++) result_types[i] = result_desc->attrs[i].atttypid; values[4] = build_regtype_array(result_types, result_desc->natts); @@ -732,7 +732,7 @@ build_regtype_array(Oid *param_types, int num_params) ArrayType *result; int i; - tmp_ary = (Datum *) palloc(num_params * sizeof(Datum)); + tmp_ary = palloc_array(Datum, num_params); for (i = 0; i < num_params; i++) tmp_ary[i] = ObjectIdGetDatum(param_types[i]); |