Skip site navigation (1) Skip section navigation (2)

Re: Faster StrNCpy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Strong, David" <david(dot)strong(at)unisys(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Faster StrNCpy
Date: 2006-09-28 15:56:04
Message-ID: 26197.1159458964@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
"Strong, David" <david(dot)strong(at)unisys(dot)com> writes:
> Just wondering - are any of these cases where a memcpy() would work
> just as well? Or are you not sure that the source string is at least
> 64 bytes in length?

In most cases, we're pretty sure that it's *not* --- it'll just be a
palloc'd C string.

I'm disinclined to fool with the restriction that namestrcpy zero-pad
Name values, because they might end up on disk, and allowing random
memory contents to get written out is ungood from a security point of
view.  However, it's entirely possible that it'd be a bit faster to do
a MemSet followed by strlcpy than to use strncpy for zero-padding.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Gevik BabakhaniDate: 2006-09-28 16:00:19
Subject: Re: Row IS NULL question
Previous:From: Tom LaneDate: 2006-09-28 15:45:32
Subject: Re: Row IS NULL question

pgsql-patches by date

Next:From: Bruce MomjianDate: 2006-09-28 17:24:30
Subject: Re: Coding style for emacs
Previous:From: Strong, DavidDate: 2006-09-28 14:51:36
Subject: Re: Faster StrNCpy

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group