Re: Avoid use scoped block variable

From: Andres Freund <andres(at)anarazel(dot)de>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid use scoped block variable
Date: 2025-12-09 16:19:06
Message-ID: dups3vodgn3ko6w7oi3rviehpl5462rvkspredynw7niaqc2ka@725gziq7647y
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2025-12-09 13:06:35 -0300, Ranier Vilela wrote:
> I noticed a possible violation of C rules.
> Some functions rely on local block variables,
> but this are a mistake.
> Once that block exits, the memory of the variable is released.

CStringGetTextDatum() copies its input to a fresh allocation. So there's no
longer-lived references to the local memory, unless I miss something?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-12-09 16:20:48 Re: Avoid use scoped block variable
Previous Message Ranier Vilela 2025-12-09 16:06:35 Avoid use scoped block variable