From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | mark(at)mark(dot)mielke(dot)cc, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [COMMITTERS] pgsql: StrNCpy -> strlcpy (not complete) |
Date: | 2007-02-11 20:02:35 |
Message-ID: | 200702112002.l1BK2ZD21589@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
Peter Eisentraut wrote:
> mark(at)mark(dot)mielke(dot)cc wrote:
> > I think we had this discussion already. strncpy() copies N bytes,
> > whereas strlcpy() copies only as many bytes as necessary. For short
> > strings with larger buffers, strlcpy() wins. It's understood that
> > in many cases in PostgreSQL, the expectation is for short strings,
> > and it is not required for the later bytes to be '\0'.
>
> You may also speculate that strncpy() is more optimized in some C
> libraries than strlcpy(). However, the changed cases are all
> uninteresting in terms of performance or fall under the short strings
> in long buffers case.
>
> The remaining uses of StrNCpy() are either inner loops which need to be
> investigated, or it's not clear whether the zero-filling of strncpy()
> is required, or it's in a library were the libpgport linkages needs to
> be added.
>
> The main idea here is to get this programming style out because it's
> become clear that people are very confused about how to use some of the
> other functions correctly.
Sorry, I was confusing this with MemSet. Thanks for the clarification.
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2007-02-11 22:18:16 | pgsql: Add support for optionally escaping periods when converting SQL |
Previous Message | User Korryd | 2007-02-11 20:01:37 | pg-migrator - src: Fixing a few usability issues, refactoring some |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2007-02-11 20:23:55 | Re: HOT for PostgreSQL 8.3 |
Previous Message | Pavel Stehule | 2007-02-11 19:38:45 | Re: wishlist items .. |