Re: Avoid use scoped block variable

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid use scoped block variable
Date: 2025-12-09 16:24:14
Message-ID: CAEudQAqepMe2cja=vPAJkzqE1To=yN6To0vqSzOdiCu9X+KWkQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em ter., 9 de dez. de 2025 às 13:19, Andres Freund <andres(at)anarazel(dot)de>
escreveu:

> 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?
>
Yeah. My bad.
cstring_to_text use palloc.

Sorry for the noise.

best regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-12-09 16:27:04 Re: Mark function arguments of type "Datum *" as "const Datum *" where possible
Previous Message Bertrand Drouvot 2025-12-09 16:20:57 Mark function arguments of type "T *" as "const T *" where possible