best place for xstrdup

From: "Mendola Gaetano" <mendola(at)bigfoot(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: best place for xstrdup
Date: 2003-09-16 14:49:03
Message-ID: 027e01c37c61$ac738670$152aa8c0@GMENDOLA2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

As suggested by Bruce Mojiman I'm working on
substitute some strdup not checked with xstrdup.

I seen that in the backend source tree there is no
xstrdup ( there is one in bin/psql tree) ,
I wrote it and inserted temporarelly in
backend/utils/mmgr/aset.c

I don't know exactly how work the error report
mechanism sso before to submit a wrong implementation
this was what I wrote:

char *xstrdup(const char *string)
{
char * ret_value;

if ( !string ) {
elog(ERROR, "xstrdup called with a NULL pointer");
}

ret_value = strdup( string );

if ( !ret_value ) {
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("strdup out of memory")));
}

return ret_value;
}

if this implementation is ok where is the best place ?

Regards
Gaetano Mendola

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-09-16 15:08:28 Re: best place for xstrdup
Previous Message Tom Lane 2003-09-16 05:33:06 Re: AIX 4.2.1 CVS head and SSL