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

Re: Faster StrNCpy

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Faster StrNCpy
Date: 2006-09-26 20:40:18
Message-ID: 20060926204018.GF19913@svana.org (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
On Tue, Sep 26, 2006 at 04:24:51PM -0400, Tom Lane wrote:
> David Strong points out here
> http://archives.postgresql.org/pgsql-hackers/2006-09/msg02071.php
> that some popular implementations of strncpy(dst,src,n) are quite
> inefficient when strlen(src) is much less than n, because they don't
> optimize the zero-pad step that is required by the standard.

I think that's why strlcpy was invented, to deal with the issues with
strncpy.

http://www.gratisoft.us/todd/papers/strlcpy.html

There's an implementation here (used in glib), though you could
probably find more.

http://mail.gnome.org/archives/gtk-devel-list/2000-May/msg00029.html

Do you really think it's worth making a macro rather than just a normal
function?

Have a nice day,
-- 
Martijn van Oosterhout   <kleptog(at)svana(dot)org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

pgsql-hackers by date

Next:From: Alvaro HerreraDate: 2006-09-26 20:49:37
Subject: Re: Faster StrNCpy
Previous:From: Dragan ZubacDate: 2006-09-26 20:39:18
Subject: PostgreSQL HA questions

pgsql-patches by date

Next:From: Alvaro HerreraDate: 2006-09-26 20:49:37
Subject: Re: Faster StrNCpy
Previous:From: Tom LaneDate: 2006-09-26 20:24:51
Subject: Faster StrNCpy

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