Re: pstrndup()

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

Karel Zak wrote:
> On Sun, Mar 21, 2004 at 11:45:18PM -0500, Tom Lane wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > Karel, do you plan to use pstrndup for some purpose? I assume so.
>
> I think PostgreSQL should supports basic operation with
> allocation/strings if it's open for users' C functions and we expect
> our own memory system usage.
>
> > I am not familiar with strndup. If the spec is like strncpy, I would
> > vote against including it ... strncpy is so broken that we had to invent
> > our own variant ...
>
> POSIX strncpy() is different, a result from strncpy needn't be zero
> terminated. You're right it's horrible function.
>
> 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.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-03-22 14:52:54 Re: [PATCHES] UnixWare/CVS Tip/initdb.c needs to use threads
Previous Message Andrew Dunstan 2004-03-22 12:54:04 Re: [HACKERS] listening addresses