pgsql: Use palloc_object() and palloc_array() in more areas of the tree

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use palloc_object() and palloc_array() in more areas of the tree
Date: 2025-12-09 05:53:54
Message-ID: E1vSqfa-003ZDP-1N@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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 <geidav(dot)pg(at)gmail(dot)com>
Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0c3c5c3b06a37c13a811ea93044202e06523b705

Modified Files
--------------
doc/src/sgml/gist.sgml | 8 +-
doc/src/sgml/xfunc.sgml | 2 +-
doc/src/sgml/xtypes.sgml | 2 +-
src/bin/pg_basebackup/astreamer_inject.c | 2 +-
src/bin/pg_combinebackup/load_manifest.c | 2 +-
src/bin/pg_dump/common.c | 2 +-
src/bin/pg_verifybackup/astreamer_verify.c | 2 +-
src/bin/pg_verifybackup/pg_verifybackup.c | 2 +-
src/bin/scripts/vacuuming.c | 2 +-
src/common/blkreftable.c | 21 +++--
src/common/parse_manifest.c | 4 +-
src/common/pgfnames.c | 5 +-
src/common/rmtree.c | 2 +-
src/common/stringinfo.c | 2 +-
src/fe_utils/astreamer_file.c | 4 +-
src/fe_utils/astreamer_gzip.c | 4 +-
src/fe_utils/astreamer_lz4.c | 4 +-
src/fe_utils/astreamer_tar.c | 6 +-
src/fe_utils/astreamer_zstd.c | 4 +-
src/include/lib/radixtree.h | 8 +-
src/pl/plperl/plperl.c | 12 +--
src/pl/plpgsql/src/pl_comp.c | 32 ++++----
src/pl/plpgsql/src/pl_exec.c | 9 +--
src/pl/plpgsql/src/pl_gram.y | 92 +++++++++++-----------
src/pl/plpython/plpy_procedure.c | 6 +-
src/pl/plpython/plpy_spi.c | 4 +-
src/pl/plpython/plpy_typeio.c | 12 +--
src/pl/tcl/pltcl.c | 4 +-
src/test/modules/dummy_index_am/dummy_index_am.c | 2 +-
src/test/modules/spgist_name_ops/spgist_name_ops.c | 10 +--
src/test/modules/test_bitmapset/test_bitmapset.c | 2 +-
src/test/modules/test_integerset/test_integerset.c | 2 +-
.../test_json_parser_incremental.c | 2 +-
src/test/modules/test_parser/test_parser.c | 4 +-
src/test/modules/test_radixtree/test_radixtree.c | 2 +-
src/test/modules/test_regex/test_regex.c | 14 ++--
.../modules/test_resowner/test_resowner_many.c | 2 +-
src/test/modules/test_rls_hooks/test_rls_hooks.c | 4 +-
src/test/modules/worker_spi/worker_spi.c | 2 +-
src/test/regress/regress.c | 2 +-
src/timezone/pgtz.c | 2 +-
src/tutorial/complex.c | 6 +-
src/tutorial/funcs.c | 2 +-
43 files changed, 156 insertions(+), 161 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2025-12-09 06:44:59 pgsql: Clean up int64-related format strings
Previous Message Andres Freund 2025-12-09 04:12:34 Re: pgsql: Add pg_atomic_unlocked_write_u64