best place for xstrdup - Mailing list pgsql-hackers

From Mendola Gaetano
Subject best place for xstrdup
Date
Msg-id 027e01c37c61$ac738670$152aa8c0@GMENDOLA2
Whole thread Raw
Responses Re: best place for xstrdup  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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





pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: AIX 4.2.1 CVS head and SSL
Next
From: Tom Lane
Date:
Subject: Re: best place for xstrdup