Use palloc_object() and palloc_array() in more areas of the tree
authorMichael Paquier <[email protected]>
Tue, 9 Dec 2025 05:53:17 +0000 (14:53 +0900)
committerMichael Paquier <[email protected]>
Tue, 9 Dec 2025 05:53:17 +0000 (14:53 +0900)
commit0c3c5c3b06a37c13a811ea93044202e06523b705
treeabcde572bfd5b10dc11476706d6616ff0cad2828
parentaa749bde323364039f369784071f315ad53c1325
Use palloc_object() and palloc_array() in more areas of the tree

The idea is to encourage more the use of these new routines across the
tree, as these offer stronger type safety guarantees than palloc().

The following paths are included in this batch, treating all the areas
proposed by the author for the most trivial changes, except src/backend
(by far the largest batch):
src/bin/
src/common/
src/fe_utils/
src/include/
src/pl/
src/test/
src/tutorial/

Similar work has been done in 31d3847a37be.

The code compiles the same before and after this commit, with the
following exceptions due to changes in line numbers because some of the
new allocation formulas are shorter:
blkreftable.c
pgfnames.c
pl_exec.c

Author: David Geier <[email protected]>
Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com
43 files changed:
doc/src/sgml/gist.sgml
doc/src/sgml/xfunc.sgml
doc/src/sgml/xtypes.sgml
src/bin/pg_basebackup/astreamer_inject.c
src/bin/pg_combinebackup/load_manifest.c
src/bin/pg_dump/common.c
src/bin/pg_verifybackup/astreamer_verify.c
src/bin/pg_verifybackup/pg_verifybackup.c
src/bin/scripts/vacuuming.c
src/common/blkreftable.c
src/common/parse_manifest.c
src/common/pgfnames.c
src/common/rmtree.c
src/common/stringinfo.c
src/fe_utils/astreamer_file.c
src/fe_utils/astreamer_gzip.c
src/fe_utils/astreamer_lz4.c
src/fe_utils/astreamer_tar.c
src/fe_utils/astreamer_zstd.c
src/include/lib/radixtree.h
src/pl/plperl/plperl.c
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/plpgsql/src/pl_gram.y
src/pl/plpython/plpy_procedure.c
src/pl/plpython/plpy_spi.c
src/pl/plpython/plpy_typeio.c
src/pl/tcl/pltcl.c
src/test/modules/dummy_index_am/dummy_index_am.c
src/test/modules/spgist_name_ops/spgist_name_ops.c
src/test/modules/test_bitmapset/test_bitmapset.c
src/test/modules/test_integerset/test_integerset.c
src/test/modules/test_json_parser/test_json_parser_incremental.c
src/test/modules/test_parser/test_parser.c
src/test/modules/test_radixtree/test_radixtree.c
src/test/modules/test_regex/test_regex.c
src/test/modules/test_resowner/test_resowner_many.c
src/test/modules/test_rls_hooks/test_rls_hooks.c
src/test/modules/worker_spi/worker_spi.c
src/test/regress/regress.c
src/timezone/pgtz.c
src/tutorial/complex.c
src/tutorial/funcs.c