Re: Faster StrNCpy

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Faster StrNCpy
Дата
Msg-id 20060926204018.GF19913@svana.org
обсуждение исходный текст
Ответ на Faster StrNCpy  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Faster StrNCpy  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: Faster StrNCpy  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Tue, Sep 26, 2006 at 04:24:51PM -0400, Tom Lane wrote:
> David Strong points out here
> http://archives.postgresql.org/pgsql-hackers/2006-09/msg02071.php
> that some popular implementations of strncpy(dst,src,n) are quite
> inefficient when strlen(src) is much less than n, because they don't
> optimize the zero-pad step that is required by the standard.

I think that's why strlcpy was invented, to deal with the issues with
strncpy.

http://www.gratisoft.us/todd/papers/strlcpy.html

There's an implementation here (used in glib), though you could
probably find more.

http://mail.gnome.org/archives/gtk-devel-list/2000-May/msg00029.html

Do you really think it's worth making a macro rather than just a normal
function?

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Faster StrNCpy
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Faster StrNCpy