Re: pgsql: Add missing string terminator

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Add missing string terminator
Date: 2025-04-30 15:33:00
Message-ID: F945C717-A609-4EAA-A412-C267B11ACEF2@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

> On 30 Apr 2025, at 15:14, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Thu, 1 May 2025 at 00:44, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:

>> I think it's best in general to use str* for strings and mem* for
>> not-strings. That's easier to read and also better for static analyzers
>> etc.
>
> The reason I think memcpy is better is that the NUL only needs to be
> found once. memcpy() is much faster than strlcpy() because it can
> operate on many bytes at once rather than doing 1 byte at a time.

I don't disagree, but since similar codepaths in this file use strlcpy now I
will opt for that for consistency (and thus readability) with a TODO item to
look at changing all these for memcpy during v19.

--
Daniel Gustafsson

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2025-04-30 17:15:46 Re: pgsql: Add function to log the memory contexts of specified backend pro
Previous Message Tom Lane 2025-04-30 15:14:44 pgsql: Update time zone data files to tzdata release 2025b.