pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
Subject: [PATCH 2/2] memory free simplify
Date: Sun, 5 Jul 2026 14:10:18 +0200

---
 src/backend/utils/error/elog.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

inline patch 1: src/backend/utils/error/elog.c (+5/-5 lines) download inline-1.patchdiff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 80d4eef755a..7d229279dbe 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2364,6 +2364,7 @@ bool check_log_min_messages(char **newval, void **extra, GucSource source) { char *rawstring; + int rawstring_len; List *elemlist; StringInfoData buf; char *result; @@ -2392,6 +2393,8 @@ check_log_min_messages(char **newval, void **extra, GucSource source) guc_free(rawstring); return false; } + rawstring_len = strlen(rawstring); + guc_free(rawstring); /* Validate and assign log level and process type. */ foreach_ptr(char, elem, elemlist) @@ -2478,7 +2481,6 @@ check_log_min_messages(char **newval, void **extra, GucSource source) continue; lmm_fail: - guc_free(rawstring); list_free(elemlist); return false; } @@ -2489,7 +2491,6 @@ lmm_fail: if (defaultlevel == -1) { GUC_check_errdetail("Default log level was not defined."); - guc_free(rawstring); list_free(elemlist); return false; } @@ -2507,7 +2508,7 @@ lmm_fail: */ list_sort(elemlist, log_min_messages_cmp); - initStringInfoExt(&buf, strlen(rawstring) + 1); + initStringInfoExt(&buf, rawstring_len + 1); foreach_ptr(char, elem, elemlist) { if (foreach_current_index(elem) == 0) @@ -2515,6 +2516,7 @@ lmm_fail: else appendStringInfo(&buf, ", %s", elem); } + list_free(elemlist); result = guc_strdup(LOG, buf.data); if (!result) @@ -2526,8 +2528,6 @@ lmm_fail: guc_free(*newval); *newval = result; - guc_free(rawstring); - list_free(elemlist); pfree(buf.data); /* -- 2.47.3
--dnohjpfxulhc3bo3--

Message-ID: <no-message-id-847325@localhost>
Permalink:  ../no-message-id-847325@localhost/
Also on:    postgresql.org/message-id/no-message-id-847325@localhost

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@kurilemu.de
  Subject: Re: [PATCH 2/2] memory free simplify
  In-Reply-To: <no-message-id-847325@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox