Re: Questions/observations about set_ps_display ()
От | Tom Lane |
---|---|
Тема | Re: Questions/observations about set_ps_display () |
Дата | |
Msg-id | 26756.1159287789@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Questions/observations about set_ps_display () ("Strong, David" <david.strong@unisys.com>) |
Список | pgsql-hackers |
"Strong, David" <david.strong@unisys.com> writes: > The specification for strncpy () indicates that when the length of the > source string (4 bytes) is less than the length of the number of bytes > to copy (2500 bytes), the remainder of the destination string will be > padded with NULL bytes (2496). Based on the GLIBC source code, strncpy > () is written to pad the destination string a byte at a time and this is > where all the time was taken, according to OProfile. Hm. In the PS_USE_CLOBBER_ARGV case, this is pretty silly considering we're going to MemSet the rest of the space anyway. We should probably replace the StrNCpy with something that doesn't uselessly fill the rest of the buffer, perhaps something likememcpy(dest, src, Min(strlen(dest) + 1, avail space)); I believe that most of our uses of StrNCpy actually do not expect the pad-out behavior, so maybe there are other uses for something along this line ... regards, tom lane
В списке pgsql-hackers по дате отправления: