Re: pstrndup()

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pstrndup()
Date: 2004-03-23 10:10:52
Message-ID: 20040323101052.GA32767@zf.jcu.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Mon, Mar 22, 2004 at 10:04:01AM -0500, Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Karel Zak wrote:
> >> The result of strndup() is always zero terminated. It's more safe and
> >> strndup() is binary safe because it doesn't check something in input
> >> string. The pstrndup() is based on PostgreSQL memory managment.
>
> > Can you find places to use this function our backend? Seems that should
> > be part of the patch.
>
> A bit of googling showed that strndup does appear in the "Linux
> standards base", but it is not to be found in the Single Unix Spec.
> That makes it at most quasi-standard IMHO.

man strndup

CONFORMING TO
SVID 3, BSD 4.3

> with strncpy). That's a lot of strikes for something that replaces only
> three lines of C ...

How often are bugs with "add '\0' to last item of array"?

Well, forget this patch...

Karel

--
Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
http://home.zf.jcu.cz/~zakkr/

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Claudio Natoli 2004-03-23 13:13:24 Re: Patch for select and APC on win32
Previous Message Magnus Hagander 2004-03-23 09:21:26 Re: Patch for select and APC on win32