Re: pnstrdup considered armed and dangerous - Mailing list pgsql-hackers

From Robert Haas
Subject Re: pnstrdup considered armed and dangerous
Date
Msg-id CA+TgmoaEa03oNe-vx1ZaeW_-dXpX1pyct=U_8vM7dNTYsxsh_Q@mail.gmail.com
Whole thread Raw
In response to pnstrdup considered armed and dangerous  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Mon, Oct 3, 2016 at 5:55 PM, Andres Freund <andres@anarazel.de> wrote:
> /*
>  * pnstrdup
>  *              Like pstrdup(), but append null byte to a
>  *              not-necessarily-null-terminated input string.
>  */
> char *
> pnstrdup(const char *in, Size len)
> {
>         char       *out = palloc(len + 1);
>
>         memcpy(out, in, len);
>         out[len] = '\0';
>         return out;
> }
>
> isn't that a somewhat weird behaviour / implementation? Not really like
> strndup(), which one might believe to be analoguous...

Yikes!

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Chenxi Li
Date:
Subject: Cardinality estimation for group by
Next
From: David Steele
Date:
Subject: Re: Renaming of pg_xlog and pg_clog