[PATCH] ecpg: use memcpy in a few length-based copies

Поиск
Список
Период
Сортировка
Искать
От
Haibo Yan
Тема
[PATCH] ecpg: use memcpy in a few length-based copies
Дата
в 22:24:22
Msg-id
CABXr29HdcPfU+wC7Va9Z5WXh+Kai_63J4J-e3d-_w=EuBNFKLw@mail.gmail.com
Список
Дерево обсуждения
[PATCH] ecpg: use memcpy in a few length-based copies Haibo Yan <tristan.yim@gmail.com>
Re: [PATCH] ecpg: use memcpy in a few length-based copies Peter Eisentraut <peter@eisentraut.org>
Re: [PATCH] ecpg: use memcpy in a few length-based copies Haibo Yan <tristan.yim@gmail.com>
Hi hackers,

I noticed a few places in ecpg that use strncpy() even though the code already
knows how many bytes to copy.

For example, some paths copy N bytes into a temporary buffer and then add the
terminating NUL explicitly.  There is also one small substring copy in
pgtypeslib/datetime.c.  memcpy() seems a better fit for those cases.

I did not try to replace all strncpy() calls in ecpg.  Some of them still need
the usual strncpy() behavior when the source string may be shorter than the
destination.

The patch also adds a small regression test for fixed-size char[] and VARCHAR
output around the exact-fit/truncation boundary.

Thanks,
Haibo
В списке pgsql-hackers по дате отправления
От: Jeff Davis
Дата:
От: Peter Geoghegan
Дата:
Сообщение: Hash index bucket split bug
FAQ