Re: Questions/observations about set_ps_display () - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Questions/observations about set_ps_display ()
Date
Msg-id 26756.1159287789@sss.pgh.pa.us
Whole thread Raw
In response to Questions/observations about set_ps_display ()  ("Strong, David" <david.strong@unisys.com>)
List 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 by date:

Previous
From: "Radovan Jablonov"
Date:
Subject: Re: [Fwd: Re: pdfs of the conference]
Next
From: Tom Lane
Date:
Subject: Re: [PATCHES] Too many messages from Autovacuum