From 1adbb47f9e716e002b6d50b84260c174eacc5431 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Sat, 8 Aug 2026 03:40:28 +0000 Subject: [PATCH v1 3/3] Migrate object-like palloc() calls to palloc_object() palloc_object() is a helper for creating type-safe object allocations. In many places, we were open coding the same pattern. This should reduce a little bit of code noise at call sites. Signed-off-by: Tristan Partin --- contrib/btree_gist/btree_bool.c | 2 +- contrib/btree_gist/btree_cash.c | 2 +- contrib/btree_gist/btree_date.c | 2 +- contrib/btree_gist/btree_enum.c | 2 +- contrib/btree_gist/btree_float4.c | 2 +- contrib/btree_gist/btree_float8.c | 2 +- contrib/btree_gist/btree_inet.c | 2 +- contrib/btree_gist/btree_int2.c | 2 +- contrib/btree_gist/btree_int4.c | 2 +- contrib/btree_gist/btree_int8.c | 2 +- contrib/btree_gist/btree_interval.c | 2 +- contrib/btree_gist/btree_macaddr.c | 2 +- contrib/btree_gist/btree_macaddr8.c | 2 +- contrib/btree_gist/btree_oid.c | 2 +- contrib/btree_gist/btree_time.c | 2 +- contrib/btree_gist/btree_ts.c | 2 +- contrib/btree_gist/btree_uuid.c | 2 +- contrib/hstore/hstore_gin.c | 2 +- contrib/pg_plan_advice/pgpa_scan.c | 2 +- contrib/pgcrypto/pgp.c | 2 +- src/backend/access/tablesample/bernoulli.c | 2 +- src/backend/commands/async.c | 2 +- src/backend/commands/tablecmds.c | 2 +- src/backend/commands/trigger.c | 2 +- src/backend/libpq/be-secure-common.c | 2 +- src/backend/libpq/be-secure-openssl.c | 2 +- src/backend/optimizer/plan/analyzejoins.c | 2 +- src/backend/optimizer/plan/initsplan.c | 2 +- src/backend/postmaster/datachecksum_state.c | 2 +- src/backend/storage/ipc/shmem.c | 2 +- src/backend/storage/lmgr/lwlock.c | 2 +- src/backend/utils/adt/ruleutils.c | 4 ++-- src/test/modules/test_rbtree/test_rbtree.c | 2 +- src/test/modules/test_saslprep/test_saslprep.c | 2 +- 34 files changed, 35 insertions(+), 35 deletions(-) diff --git a/contrib/btree_gist/btree_bool.c b/contrib/btree_gist/btree_bool.c index 8a79c7a0db7..febd1ba1f34 100644 --- a/contrib/btree_gist/btree_bool.c +++ b/contrib/btree_gist/btree_bool.c @@ -129,7 +129,7 @@ Datum gbt_bool_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(boolKEY)); + void *out = palloc_object(boolKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(boolKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_cash.c b/contrib/btree_gist/btree_cash.c index e5427e53180..f5ecce2c68c 100644 --- a/contrib/btree_gist/btree_cash.c +++ b/contrib/btree_gist/btree_cash.c @@ -179,7 +179,7 @@ Datum gbt_cash_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(cashKEY)); + void *out = palloc_object(cashKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(cashKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_date.c b/contrib/btree_gist/btree_date.c index 92c725664dd..1824a3d0e6e 100644 --- a/contrib/btree_gist/btree_date.c +++ b/contrib/btree_gist/btree_date.c @@ -194,7 +194,7 @@ Datum gbt_date_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(dateKEY)); + void *out = palloc_object(dateKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(dateKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_enum.c b/contrib/btree_gist/btree_enum.c index e95ac926c93..386c92b6e9e 100644 --- a/contrib/btree_gist/btree_enum.c +++ b/contrib/btree_gist/btree_enum.c @@ -148,7 +148,7 @@ Datum gbt_enum_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(oidKEY)); + void *out = palloc_object(oidKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_float4.c b/contrib/btree_gist/btree_float4.c index df0a1908db6..a8121ba9961 100644 --- a/contrib/btree_gist/btree_float4.c +++ b/contrib/btree_gist/btree_float4.c @@ -198,7 +198,7 @@ Datum gbt_float4_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(float4KEY)); + void *out = palloc_object(float4KEY); *(int *) PG_GETARG_POINTER(1) = sizeof(float4KEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_float8.c b/contrib/btree_gist/btree_float8.c index 41db58e2602..478324ce4f3 100644 --- a/contrib/btree_gist/btree_float8.c +++ b/contrib/btree_gist/btree_float8.c @@ -200,7 +200,7 @@ Datum gbt_float8_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(float8KEY)); + void *out = palloc_object(float8KEY); *(int *) PG_GETARG_POINTER(1) = sizeof(float8KEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_inet.c b/contrib/btree_gist/btree_inet.c index 146f3cb6494..4584b32c150 100644 --- a/contrib/btree_gist/btree_inet.c +++ b/contrib/btree_gist/btree_inet.c @@ -146,7 +146,7 @@ Datum gbt_inet_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(inetKEY)); + void *out = palloc_object(inetKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(inetKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_int2.c b/contrib/btree_gist/btree_int2.c index 4d03fb2aa36..6d5ca44fe8f 100644 --- a/contrib/btree_gist/btree_int2.c +++ b/contrib/btree_gist/btree_int2.c @@ -178,7 +178,7 @@ Datum gbt_int2_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(int16KEY)); + void *out = palloc_object(int16KEY); *(int *) PG_GETARG_POINTER(1) = sizeof(int16KEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_int4.c b/contrib/btree_gist/btree_int4.c index 2db4baa0926..8e0c010c633 100644 --- a/contrib/btree_gist/btree_int4.c +++ b/contrib/btree_gist/btree_int4.c @@ -176,7 +176,7 @@ Datum gbt_int4_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(int32KEY)); + void *out = palloc_object(int32KEY); *(int *) PG_GETARG_POINTER(1) = sizeof(int32KEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_int8.c b/contrib/btree_gist/btree_int8.c index 4b2333cb315..ed55ac8dbfd 100644 --- a/contrib/btree_gist/btree_int8.c +++ b/contrib/btree_gist/btree_int8.c @@ -178,7 +178,7 @@ Datum gbt_int8_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(int64KEY)); + void *out = palloc_object(int64KEY); *(int *) PG_GETARG_POINTER(1) = sizeof(int64KEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_interval.c b/contrib/btree_gist/btree_interval.c index d671092ca41..77f9f282714 100644 --- a/contrib/btree_gist/btree_interval.c +++ b/contrib/btree_gist/btree_interval.c @@ -252,7 +252,7 @@ Datum gbt_intv_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(intvKEY)); + void *out = palloc_object(intvKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(intvKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_macaddr.c b/contrib/btree_gist/btree_macaddr.c index 97f088d7795..7ed8499adcf 100644 --- a/contrib/btree_gist/btree_macaddr.c +++ b/contrib/btree_gist/btree_macaddr.c @@ -148,7 +148,7 @@ Datum gbt_macad_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc0(sizeof(macKEY)); + void *out = palloc0_object(macKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(macKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_macaddr8.c b/contrib/btree_gist/btree_macaddr8.c index 53d10612018..b51e738f7e6 100644 --- a/contrib/btree_gist/btree_macaddr8.c +++ b/contrib/btree_gist/btree_macaddr8.c @@ -146,7 +146,7 @@ Datum gbt_macad8_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc0(sizeof(mac8KEY)); + void *out = palloc0_object(mac8KEY); *(int *) PG_GETARG_POINTER(1) = sizeof(mac8KEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_oid.c b/contrib/btree_gist/btree_oid.c index a33ceb32883..ccaa150528a 100644 --- a/contrib/btree_gist/btree_oid.c +++ b/contrib/btree_gist/btree_oid.c @@ -178,7 +178,7 @@ Datum gbt_oid_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(oidKEY)); + void *out = palloc_object(oidKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c index 9496112889d..c4f9f19c411 100644 --- a/contrib/btree_gist/btree_time.c +++ b/contrib/btree_gist/btree_time.c @@ -259,7 +259,7 @@ Datum gbt_time_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(timeKEY)); + void *out = palloc_object(timeKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(timeKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c index 9f3a51ad728..53d63e5c852 100644 --- a/contrib/btree_gist/btree_ts.c +++ b/contrib/btree_gist/btree_ts.c @@ -329,7 +329,7 @@ Datum gbt_ts_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(tsKEY)); + void *out = palloc_object(tsKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(tsKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/btree_gist/btree_uuid.c b/contrib/btree_gist/btree_uuid.c index 354d6819b9e..624333ff557 100644 --- a/contrib/btree_gist/btree_uuid.c +++ b/contrib/btree_gist/btree_uuid.c @@ -158,7 +158,7 @@ Datum gbt_uuid_union(PG_FUNCTION_ARGS) { GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0); - void *out = palloc(sizeof(uuidKEY)); + void *out = palloc_object(uuidKEY); *(int *) PG_GETARG_POINTER(1) = sizeof(uuidKEY); PG_RETURN_POINTER(gbt_num_union(out, entryvec, &tinfo, fcinfo->flinfo)); diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c index a5fdc676c96..a0aa7aed7c7 100644 --- a/contrib/hstore/hstore_gin.c +++ b/contrib/hstore/hstore_gin.c @@ -103,7 +103,7 @@ gin_extract_hstore_query(PG_FUNCTION_ARGS) text *item; *nentries = 1; - entries = (Datum *) palloc(sizeof(Datum)); + entries = palloc_object(Datum); item = makeitem(VARDATA_ANY(query), VARSIZE_ANY_EXHDR(query), KEYFLAG); entries[0] = PointerGetDatum(item); } diff --git a/contrib/pg_plan_advice/pgpa_scan.c b/contrib/pg_plan_advice/pgpa_scan.c index 4da77936216..1d8894e5440 100644 --- a/contrib/pg_plan_advice/pgpa_scan.c +++ b/contrib/pg_plan_advice/pgpa_scan.c @@ -245,7 +245,7 @@ pgpa_make_scan(pgpa_plan_walker_context *walker, Plan *plan, pgpa_scan *scan; /* Create the scan object. */ - scan = palloc(sizeof(pgpa_scan)); + scan = palloc_object(pgpa_scan); scan->plan = plan; scan->strategy = strategy; scan->relids = relids; diff --git a/contrib/pgcrypto/pgp.c b/contrib/pgcrypto/pgp.c index 8a6a6c2adf1..4e8b4f8827b 100644 --- a/contrib/pgcrypto/pgp.c +++ b/contrib/pgcrypto/pgp.c @@ -190,7 +190,7 @@ pgp_init(PGP_Context **ctx_p) { PGP_Context *ctx; - ctx = palloc0(sizeof *ctx); + ctx = palloc0_object(PGP_Context); ctx->cipher_algo = def_cipher_algo; ctx->s2k_cipher_algo = def_s2k_cipher_algo; diff --git a/src/backend/access/tablesample/bernoulli.c b/src/backend/access/tablesample/bernoulli.c index 7d8560464c8..a8ec1e1b9ac 100644 --- a/src/backend/access/tablesample/bernoulli.c +++ b/src/backend/access/tablesample/bernoulli.c @@ -126,7 +126,7 @@ bernoulli_samplescangetsamplesize(PlannerInfo *root, static void bernoulli_initsamplescan(SampleScanState *node, int eflags) { - node->tsm_state = palloc0(sizeof(BernoulliSamplerData)); + node->tsm_state = palloc0_object(BernoulliSamplerData); } /* diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 2799f989b96..4069dde3ba6 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -1109,7 +1109,7 @@ pg_listening_channels(PG_FUNCTION_ARGS) MemoryContext oldcontext; oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); - status = (HASH_SEQ_STATUS *) palloc(sizeof(HASH_SEQ_STATUS)); + status = palloc_object(HASH_SEQ_STATUS); hash_seq_init(status, localChannelTable); funcctx->user_fctx = status; MemoryContextSwitchTo(oldcontext); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index f1a672c4cc4..29e0e6a92c3 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -23609,7 +23609,7 @@ collectPartitionIndexExtDeps(List *partitionOids) if (!OidIsValid(parentIndexOid)) continue; - entry = palloc(sizeof(PartitionIndexExtDepEntry)); + entry = palloc_object(PartitionIndexExtDepEntry); entry->parentIndexOid = parentIndexOid; entry->indexOid = indexOid; entry->extensionOids = getAutoExtensionsOfObject(RelationRelationId, diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 67355147ba2..28a2731058c 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -6884,7 +6884,7 @@ RegisterAfterTriggerBatchCallback(AfterTriggerBatchCallback callback, Assert(afterTriggers.firing_depth > 0); Assert(!afterTriggers.firing_batch_callbacks); oldcxt = MemoryContextSwitchTo(TopTransactionContext); - item = palloc(sizeof(AfterTriggerCallbackItem)); + item = palloc_object(AfterTriggerCallbackItem); item->callback = callback; item->arg = arg; if (afterTriggers.query_depth >= 0) diff --git a/src/backend/libpq/be-secure-common.c b/src/backend/libpq/be-secure-common.c index 6ec887b8a47..64fd9364b79 100644 --- a/src/backend/libpq/be-secure-common.c +++ b/src/backend/libpq/be-secure-common.c @@ -199,7 +199,7 @@ parse_hosts_line(TokenizedAuthLine *tok_line, int elevel) ListCell *field; AuthToken *token; - parsedline = palloc0(sizeof(HostsLine)); + parsedline = palloc0_object(HostsLine); parsedline->sourcefile = pstrdup(tok_line->file_name); parsedline->linenumber = tok_line->line_num; parsedline->rawline = pstrdup(tok_line->raw_line); diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index 04764700845..66de76877ba 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -333,7 +333,7 @@ be_tls_init(bool isServerStart) */ else if (res == HOSTSFILE_DISABLED || res == HOSTSFILE_EMPTY || res == HOSTSFILE_MISSING) { - HostsLine *pgconf = palloc0(sizeof(HostsLine)); + HostsLine *pgconf = palloc0_object(HostsLine); #ifdef USE_ASSERT_CHECKING if (res == HOSTSFILE_DISABLED) diff --git a/src/backend/optimizer/plan/analyzejoins.c b/src/backend/optimizer/plan/analyzejoins.c index 881950e5264..87a5d9d58b8 100644 --- a/src/backend/optimizer/plan/analyzejoins.c +++ b/src/backend/optimizer/plan/analyzejoins.c @@ -1252,7 +1252,7 @@ rel_is_distinct_for(PlannerInfo *root, RelOptInfo *rel, List *clause_list, var->varno != relid || var->varlevelsup != 0) continue; - dcinfo = palloc(sizeof(DistinctColInfo)); + dcinfo = palloc_object(DistinctColInfo); dcinfo->colno = var->varattno; dcinfo->opid = opexpr->opno; dcinfo->collid = opexpr->inputcollid; diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index b38422c47a4..f08a918146c 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -490,7 +490,7 @@ remove_useless_groupby_columns(PlannerInfo *root) groupbyattnos[relid] = bms_add_member(groupbyattnos[relid], var->varattno - FirstLowInvalidHeapAttributeNumber); - info = palloc(sizeof(GroupByColInfo)); + info = palloc_object(GroupByColInfo); info->attno = var->varattno; info->eq_opfamilies = get_mergejoin_opfamilies(sgc->eqop); info->coll = var->varcollid; diff --git a/src/backend/postmaster/datachecksum_state.c b/src/backend/postmaster/datachecksum_state.c index be308a282d5..3406f352357 100644 --- a/src/backend/postmaster/datachecksum_state.c +++ b/src/backend/postmaster/datachecksum_state.c @@ -1528,7 +1528,7 @@ BuildDatabaseList(void) oldctx = MemoryContextSwitchTo(ctx); - db = (DataChecksumsWorkerDatabase *) palloc0(sizeof(DataChecksumsWorkerDatabase)); + db = palloc0_object(DataChecksumsWorkerDatabase); db->dboid = pgdb->oid; db->dbname = pstrdup(NameStr(pgdb->datname)); diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index a3d56cf55dd..228871d2525 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -374,7 +374,7 @@ ShmemRequestInternal(ShmemStructOpts *options, ShmemRequestKind kind) } /* Request looks valid, remember it */ - request = palloc(sizeof(ShmemRequest)); + request = palloc_object(ShmemRequest); request->options = options; request->kind = kind; pending_shmem_requests = lappend(pending_shmem_requests, request); diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index b1ad396ba79..82a1d4d2e26 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -655,7 +655,7 @@ RequestNamedLWLockTranche(const char *tranche_name, int num_lwlocks) else oldcontext = MemoryContextSwitchTo(TopMemoryContext); - request = palloc0(sizeof(NamedLWLockTrancheRequest)); + request = palloc0_object(NamedLWLockTrancheRequest); strlcpy(request->tranche_name, tranche_name, NAMEDATALEN); request->num_lwlocks = num_lwlocks; NamedLWLockTrancheRequests = lappend(NamedLWLockTrancheRequests, request); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 759ea6b06c1..e476cc9ac85 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -4412,7 +4412,7 @@ set_deparse_for_query(deparse_namespace *dpns, Query *query, dpns->rtable_columns = NIL; while (list_length(dpns->rtable_columns) < list_length(dpns->rtable)) dpns->rtable_columns = lappend(dpns->rtable_columns, - palloc0(sizeof(deparse_columns))); + palloc0_object(deparse_columns)); /* If it's a utility query, it won't have a jointree */ if (query->jointree) @@ -4468,7 +4468,7 @@ set_simple_column_names(deparse_namespace *dpns) dpns->rtable_columns = NIL; while (list_length(dpns->rtable_columns) < list_length(dpns->rtable)) dpns->rtable_columns = lappend(dpns->rtable_columns, - palloc0(sizeof(deparse_columns))); + palloc0_object(deparse_columns)); /* Assign unique column aliases within each non-join RTE */ forboth(lc, dpns->rtable, lc2, dpns->rtable_columns) diff --git a/src/test/modules/test_rbtree/test_rbtree.c b/src/test/modules/test_rbtree/test_rbtree.c index f99ef11e7bd..20a07900152 100644 --- a/src/test/modules/test_rbtree/test_rbtree.c +++ b/src/test/modules/test_rbtree/test_rbtree.c @@ -63,7 +63,7 @@ irbt_combine(RBTNode *existing, const RBTNode *newdata, void *arg) static RBTNode * irbt_alloc(void *arg) { - return (RBTNode *) palloc(sizeof(IntRBTreeNode)); + return (RBTNode *) palloc_object(IntRBTreeNode); } /* Node freer */ diff --git a/src/test/modules/test_saslprep/test_saslprep.c b/src/test/modules/test_saslprep/test_saslprep.c index eb211b3d679..bba4b8d6d93 100644 --- a/src/test/modules/test_saslprep/test_saslprep.c +++ b/src/test/modules/test_saslprep/test_saslprep.c @@ -168,7 +168,7 @@ test_saslprep_ranges(PG_FUNCTION_ARGS) funcctx->tuple_desc = tupdesc; /* Allocate context with range setup */ - ctx = (pg_saslprep_test_context *) palloc(sizeof(pg_saslprep_test_context)); + ctx = palloc_object(pg_saslprep_test_context); ctx->current_range = 0; ctx->current_codepoint = pg_utf8_test_ranges[0].start_codepoint; funcctx->user_fctx = ctx; -- Tristan Partin https://tristan.partin.io