From cbf1484a143359c940924418beb5ce4a7183d7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <41448637+mkgrgis@users.noreply.github.com> Date: Mon, 7 Apr 2025 16:21:37 +0300 Subject: [PATCH] Update uuid_bytea.c Delete magic numbers, constants instead --- postgresql/uuid_bytea/uuid_bytea.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgresql/uuid_bytea/uuid_bytea.c b/postgresql/uuid_bytea/uuid_bytea.c index cdf1d85..95b04f7 100644 --- a/postgresql/uuid_bytea/uuid_bytea.c +++ b/postgresql/uuid_bytea/uuid_bytea.c @@ -34,7 +34,7 @@ bytea_to_uuid(PG_FUNCTION_ARGS) pg_uuid_t *uuid; inbytea = PG_DETOAST_DATUM(PG_GETARG_BYTEA_P(0)); - if (VARSIZE_ANY_EXHDR(inbytea) != 16) + if (VARSIZE_ANY_EXHDR(inbytea) != UUID_LEN) { ereport(ERROR, (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH), @@ -51,8 +51,8 @@ bytea_to_uuid(PG_FUNCTION_ARGS) * * If you use this in production, I'll hurt you. */ - uuid = (pg_uuid_t*)palloc(16); - memcpy(uuid, VARDATA_ANY(inbytea), 16); + uuid = (pg_uuid_t*)palloc(UUID_LEN); + memcpy(uuid, VARDATA_ANY(inbytea), UUID_LEN); PG_RETURN_UUID_P(uuid); }