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

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-22 07:05:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
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.


 Karel Zak  <zakkr(at)zf(dot)jcu(dot)cz>

In response to


pgsql-patches by date

Next:From: Fabien COELHODate: 2004-03-22 08:40:54
Subject: Re: Syntax error reporting (was Re: [PATCHES] syntax error position
Previous:From: Manfred SpraulDate: 2004-03-22 06:12:59
Subject: Re: [HACKERS] libpq thread safety

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