Re: mcxt.c - Mailing list pgsql-patches

From Tom Lane
Subject Re: mcxt.c
Date
Msg-id 16392.1062981833@sss.pgh.pa.us
Whole thread Raw
In response to mcxt.c  ("Mendola Gaetano" <mendola@bigfoot.com>)
List pgsql-patches
"Mendola Gaetano" <mendola@bigfoot.com> writes:
> A test for null string is missing here:

> MemoryContextStrdup(MemoryContext context, const char *string)
> {
> char *nstr;
> -
> - if ( !string )
> - {
> - elog(ERROR, "MemoryContextStrdup called with a NULL pointer");
> - return NULL;
> - }

This seems inappropriate to me.  Are you going to suggest that every
routine that takes a pointer parameter needs to explicitly test for
null?  We could bloat the code a great deal that way, and slow it down,
without gaining anything at all in debuggability (IMHO anyway).

If there's a reason for pstrdup in particular to do this, what is it?

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Index creation takes for ever
Next
From: Tom Lane
Date:
Subject: Re: Unixware 713 probs