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

Re: Faster StrNCpy

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Faster StrNCpy
Date: 2006-09-26 21:03:50
Message-ID: 1159304630.1462.15.camel@localhost.localdomain (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
On Tue, 2006-09-26 at 16:53 -0400, Tom Lane wrote:
> strlcpy does more than we need (note that none of the existing uses care
> about counting the overflowed bytes).  Not sure if it's worth adopting
> those semantics when they're not really standard, but if you think a lot
> of people would be familiar with strlcpy, maybe we should.

I think we should -- while strlcpy() is not standardized, it is widely
used (in libc on all the BSDs, Solaris and OS X, as well as private
copies in Linux, glib, etc.).

A wholesale replacement of strncpy() calls is probably worth doing --
replacing them with strlcpy() if the source string is NUL-terminated,
and I suppose memcpy() otherwise.

-Neil



In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2006-09-26 21:04:14
Subject: Re: Faster StrNCpy
Previous:From: Tom LaneDate: 2006-09-26 20:53:59
Subject: Re: Faster StrNCpy

pgsql-patches by date

Next:From: Tom LaneDate: 2006-09-26 21:04:14
Subject: Re: Faster StrNCpy
Previous:From: Tom LaneDate: 2006-09-26 20:53:59
Subject: Re: Faster StrNCpy

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