SetVariable - Mailing list pgsql-hackers

From Mendola Gaetano
Subject SetVariable
Date
Msg-id 000b01c36cab$b9fe8b20$152aa8c0@GMENDOLA2
Whole thread Raw
Responses Re: SetVariable
List pgsql-hackers
Hi all, 
I found this code on the file variables.c and
in the function SetVariable I read:

if (strcmp(current->name, name) == 0)
{                 free(current->value);          current->value = strdup(value);          return current->value ? true
:false;
 
}

this mean that if there is no memory left on the
sistem we loose the old value, 
if this is not the indeended behaviour may be is better do:

if (strcmp(current->name, name) == 0)
{                 char * tmp_value = strdup(value);
          if ( !tmp_value )           {                 return false;          }               free(current->value);
     current->value = tmp_value;
 
          return true;
}


Regards
Gaetano Mendola



pgsql-hackers by date:

Previous
From: Kevin Brown
Date:
Subject: Re: set constraints docs page
Next
From: Robert Treat
Date:
Subject: Re: NOTICE vs WARNING