Re: valgrind error in tsvectorin

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: valgrind error in tsvectorin
Дата
Msg-id 3274.1242342130@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: valgrind error in tsvectorin  (Greg Stark <stark@enterprisedb.com>)
Список pgsql-hackers
Greg Stark <stark@enterprisedb.com> writes:
>> Yeah, it looks like the memcpy is sometimes unnecessary because res and
>> ptr point to the same place. �It might be worth cleaning up just to
>> avoid the valgrind warning, but I doubt it would save any noticeable
>> number of cycles.

> I assume valgrind is warning about it because memcpy's behaviour is
> undefined if the blocks overlap. I'm having trouble imagining an
> implementation that would fail if they're precisely the same pointer
> though.

Me either.  A counterexample is that compilers typically implement
structure assignment via memcpy, and the behavior of "*d = *s" is
not undefined merely because d and s point to the same place.

In this particular example it looks like res and ptr might be the same
often enough that adding an "if (res != ptr)" test would save enough
cycles to be worth its cost ... but it's pretty marginal.
        regards, tom lane


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Translation updates
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Translation updates