pgsql: Use more palloc_object() and palloc_array() in contrib/

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use more palloc_object() and palloc_array() in contrib/
Date: 2025-12-05 07:40:55
Message-ID: E1vRQQx-002u1u-0w@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use more palloc_object() and palloc_array() in contrib/

The idea is to encourage more the use of these new routines across the
tree, as these offer stronger type safety guarantees than palloc(). In
an ideal world, palloc() would then act as an internal routine of these
flavors, whose footprint in the tree is minimal.

The patch sent by the author is very large, and this chunk of changes
represents something like 10% of the overall patch submitted.

The code compiled is the same before and after this commit, using
objdump to do some validation with a difference taken in-between. There
are some diffs, which are caused by changes in line numbers because some
of the new allocation formulas are shorter, for the following files:
trgm_regexp.c, xpath.c and pg_walinspect.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/31d3847a37bec060fb4177b2fc6c0fdfc7a08011

Modified Files
--------------
contrib/amcheck/verify_gin.c | 12 ++++++------
contrib/amcheck/verify_heapam.c | 2 +-
contrib/amcheck/verify_nbtree.c | 2 +-
contrib/basebackup_to_shell/basebackup_to_shell.c | 2 +-
contrib/bloom/blinsert.c | 2 +-
contrib/bloom/blscan.c | 4 ++--
contrib/bloom/blutils.c | 2 +-
contrib/bloom/blvacuum.c | 4 ++--
contrib/btree_gin/btree_gin.c | 20 ++++++++++----------
contrib/btree_gist/btree_inet.c | 4 ++--
contrib/btree_gist/btree_interval.c | 6 +++---
contrib/btree_gist/btree_time.c | 4 ++--
contrib/btree_gist/btree_ts.c | 8 ++++----
contrib/btree_gist/btree_utils_num.c | 4 ++--
contrib/btree_gist/btree_utils_var.c | 6 +++---
contrib/btree_gist/btree_uuid.c | 2 +-
contrib/cube/cube.c | 2 +-
contrib/dict_int/dict_int.c | 4 ++--
contrib/dict_xsyn/dict_xsyn.c | 8 ++++----
contrib/file_fdw/file_fdw.c | 4 ++--
contrib/hstore/hstore_gist.c | 6 +++---
contrib/hstore/hstore_io.c | 2 +-
contrib/intarray/_int_bool.c | 8 ++++----
contrib/intarray/_int_gin.c | 4 ++--
contrib/intarray/_int_gist.c | 12 ++++++------
contrib/intarray/_intbig_gist.c | 6 +++---
contrib/jsonb_plperl/jsonb_plperl.c | 2 +-
contrib/jsonb_plpython/jsonb_plpython.c | 2 +-
contrib/ltree/_ltree_gist.c | 6 +++---
contrib/ltree/_ltree_op.c | 2 +-
contrib/ltree/ltree_gist.c | 6 +++---
contrib/ltree/ltree_io.c | 6 +++---
contrib/ltree/ltree_op.c | 2 +-
contrib/ltree/ltxtquery_io.c | 8 ++++----
contrib/pageinspect/brinfuncs.c | 2 +-
contrib/pageinspect/btreefuncs.c | 6 +++---
contrib/pageinspect/ginfuncs.c | 2 +-
contrib/pageinspect/hashfuncs.c | 2 +-
contrib/pageinspect/heapfuncs.c | 4 ++--
contrib/pg_overexplain/pg_overexplain.c | 2 +-
contrib/pg_trgm/trgm_gin.c | 8 ++++----
contrib/pg_trgm/trgm_gist.c | 10 +++++-----
contrib/pg_trgm/trgm_regexp.c | 22 ++++++++++------------
contrib/pg_visibility/pg_visibility.c | 2 +-
contrib/pg_walinspect/pg_walinspect.c | 5 ++---
contrib/pgcrypto/mbuf.c | 8 ++++----
contrib/pgcrypto/openssl.c | 4 ++--
contrib/pgcrypto/pgp-cfb.c | 2 +-
contrib/pgcrypto/pgp-compress.c | 4 ++--
contrib/pgcrypto/pgp-decrypt.c | 4 ++--
contrib/pgcrypto/pgp-encrypt.c | 4 ++--
contrib/pgcrypto/pgp-pgsql.c | 6 +++---
contrib/pgcrypto/pgp-pubkey.c | 2 +-
contrib/pgcrypto/px-hmac.c | 2 +-
contrib/pgcrypto/px.c | 2 +-
contrib/seg/seg.c | 10 +++++-----
contrib/sepgsql/label.c | 2 +-
contrib/sepgsql/uavc.c | 2 +-
contrib/spi/refint.c | 2 +-
contrib/sslinfo/sslinfo.c | 2 +-
contrib/tablefunc/tablefunc.c | 4 ++--
contrib/test_decoding/test_decoding.c | 2 +-
contrib/tsm_system_rows/tsm_system_rows.c | 2 +-
contrib/tsm_system_time/tsm_system_time.c | 2 +-
contrib/unaccent/unaccent.c | 8 ++++----
contrib/xml2/xpath.c | 3 +--
contrib/xml2/xslt_proc.c | 2 +-
67 files changed, 157 insertions(+), 161 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-05 09:48:49 pgsql: Fix setting next multixid's offset at offset wraparound
Previous Message Michael Paquier 2025-12-05 05:16:17 pgsql: Improve test output of extended statistics for ndistinct and dep