summaryrefslogtreecommitdiff
path: root/src/backend/libpq/auth-oauth.c
diff options
context:
space:
mode:
authorMichael Paquier2025-12-09 22:36:46 +0000
committerMichael Paquier2025-12-09 22:36:46 +0000
commit1b105f9472bdb9a68f709778afafb494997267bd (patch)
tree205727d30b0dd4f3060bc1f49a9efa724ee3ff80 /src/backend/libpq/auth-oauth.c
parentc507ba55f5bfae900baa94f1c657e1d99da5c6dc (diff)
Use palloc_object() and palloc_array() in backend code
The idea is to encourage more the use of these new routines across the tree, as these offer stronger type safety guarantees than palloc(). This batch of changes includes most of the trivial changes suggested by the author for src/backend/. A total of 334 files are updated here. Among these files, 48 of them have their build change slightly; these are caused by line number changes as the new allocation formulas are simpler, shaving around 100 lines of code in total. Similar work has been done in 0c3c5c3b06a3 and 31d3847a37be. Author: David Geier <geidav.pg@gmail.com> Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com
Diffstat (limited to 'src/backend/libpq/auth-oauth.c')
-rw-r--r--src/backend/libpq/auth-oauth.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/libpq/auth-oauth.c b/src/backend/libpq/auth-oauth.c
index 27f7af7be00..32a370ede11 100644
--- a/src/backend/libpq/auth-oauth.c
+++ b/src/backend/libpq/auth-oauth.c
@@ -108,7 +108,7 @@ oauth_init(Port *port, const char *selected_mech, const char *shadow_pass)
errcode(ERRCODE_PROTOCOL_VIOLATION),
errmsg("client selected an invalid SASL authentication mechanism"));
- ctx = palloc0(sizeof(*ctx));
+ ctx = palloc0_object(struct oauth_ctx);
ctx->state = OAUTH_STATE_INIT;
ctx->port = port;
@@ -656,7 +656,7 @@ validate(Port *port, const char *auth)
errmsg("validation of OAuth token requested without a validator loaded"));
/* Call the validation function from the validator module */
- ret = palloc0(sizeof(ValidatorModuleResult));
+ ret = palloc0_object(ValidatorModuleResult);
if (!ValidatorCallbacks->validate_cb(validator_module_state, token,
port->user_name, ret))
{
@@ -785,14 +785,14 @@ load_validator_library(const char *libname)
"OAuth validator", libname, "validate_cb"));
/* Allocate memory for validator library private state data */
- validator_module_state = (ValidatorModuleState *) palloc0(sizeof(ValidatorModuleState));
+ validator_module_state = palloc0_object(ValidatorModuleState);
validator_module_state->sversion = PG_VERSION_NUM;
if (ValidatorCallbacks->startup_cb != NULL)
ValidatorCallbacks->startup_cb(validator_module_state);
/* Shut down the library before cleaning up its state. */
- mcb = palloc0(sizeof(*mcb));
+ mcb = palloc0_object(MemoryContextCallback);
mcb->func = shutdown_validator_library;
MemoryContextRegisterResetCallback(CurrentMemoryContext, mcb);