| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se> |
| Cc: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: pgsql: Add missing string terminator |
| Date: | 2025-04-30 12:44:41 |
| Message-ID: | 0755ae22-4e04-4c69-b344-8c4db54d6e23@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
On 30.04.25 13:56, David Rowley wrote:
> On Wed, 30 Apr 2025 at 23:43, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>> memcpy() would make more sense IMO, since the length is
>> known already. I'm fine with either, however.
>
> In case you're looking for inspiration on a standard to follow,
> commits such as 586dd5d6a did seem to favour memcpy() when the length
> was known and only use strlcpy() when it wasn't.
It looks like the memcpy() uses in that commit are for cases where we
don't want/need the null terminator.
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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2025-04-30 13:14:57 | Re: pgsql: Add missing string terminator |
| Previous Message | David Rowley | 2025-04-30 11:56:08 | Re: pgsql: Add missing string terminator |