Re: pstrndup()

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

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.

Like Bruce, I'd like to see a more convincing use-case before adopting
not-very-standard functions. I don't think people will expect pstrndup
to exist, or be very likely to use it if it's there, or necessarily know
what its behavior is (for sure I was confused by the naming similarity
with strncpy). That's a lot of strikes for something that replaces only
three lines of C ...

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-03-22 15:12:01 Re: Syntax error reporting (was Re: [PATCHES] syntax error position "CREATE FUNCTION" bug fix)
Previous Message Bruce Momjian 2004-03-22 14:52:54 Re: [PATCHES] UnixWare/CVS Tip/initdb.c needs to use threads