Use pg_malloc_object() and pg_alloc_array() variants in frontend code

Michael Paquier <michael@paquier.xyz>

Commit: 574bee89c237d79e4dd3209f0fa3b10e0179b57a
Author: Michael Paquier <michael@paquier.xyz>
Date: 2026-02-27T09:59:41Z
Use pg_malloc_object() and pg_alloc_array() variants in frontend code

This commit updates the frontend tools (src/bin/, contrib/ and
src/test/) to use the memory allocation variants based on
pg_malloc_object() and pg_malloc_array() in various code paths.  This
does not cover all the allocations, but a good chunk of them.

Like all the changes of this kind (31d3847a37be, etc.), this should
encourage any future code to use this new style.

Author: Andreas Karlsson <andreas@proxel.se>
Discussion: https://postgr.es/m/cfb645da-6b3a-4f22-9bcc-5bc46b0e9c61@proxel.se

Files

PathChange+/−
contrib/oid2name/oid2name.c modified +8 −8
src/bin/initdb/initdb.c modified +3 −3
src/bin/pg_amcheck/pg_amcheck.c modified +4 −4
src/bin/pg_basebackup/pg_basebackup.c modified +2 −2
src/bin/pg_basebackup/pg_recvlogical.c modified +1 −1
src/bin/pg_basebackup/streamutil.c modified +4 −4
src/bin/pg_basebackup/walmethods.c modified +7 −7
src/bin/pgbench/exprparse.y modified +8 −8
src/bin/pgbench/pgbench.c modified +11 −11
src/bin/pg_combinebackup/load_manifest.c modified +2 −2
src/bin/pg_combinebackup/pg_combinebackup.c modified +3 −3
src/bin/pg_combinebackup/reconstruct.c modified +5 −5
src/bin/pg_combinebackup/write_manifest.c modified +1 −1
src/bin/pg_ctl/pg_ctl.c modified +2 −2
src/bin/pg_rewind/datapagemap.c modified +1 −1
src/bin/pg_rewind/libpq_source.c modified +1 −1
src/bin/pg_rewind/local_source.c modified +1 −1
src/bin/pg_rewind/pg_rewind.c modified +1 −1
src/bin/pg_rewind/timeline.c modified +3 −3
src/bin/pg_upgrade/check.c modified +2 −2
src/bin/pg_upgrade/function.c modified +2 −2
src/bin/pg_upgrade/info.c modified +5 −6
src/bin/pg_upgrade/parallel.c modified +6 −6
src/bin/pg_upgrade/slru_io.c modified +1 −1
src/bin/pg_upgrade/tablespace.c modified +2 −2
src/bin/pg_upgrade/task.c modified +4 −4
src/bin/pg_verifybackup/astreamer_verify.c modified +1 −1
src/bin/pg_verifybackup/pg_verifybackup.c modified +3 −3
src/bin/psql/command.c modified +3 −3
src/bin/psql/copy.c modified +1 −1
src/bin/psql/crosstabview.c modified +6 −9
src/bin/psql/describe.c modified +2 −2
src/bin/psql/tab-complete.in.c modified +3 −4
src/bin/psql/variables.c modified +3 −3
src/bin/scripts/reindexdb.c modified +3 −3
src/test/isolation/isolationtester.c modified +6 −6
src/test/isolation/specparse.y modified +25 −25
src/test/modules/libpq_pipeline/libpq_pipeline.c modified +4 −4
src/test/regress/pg_regress.c modified +3 −3

Discussion