Re: SetVariable - Mailing list pgsql-hackers

From Mendola Gaetano
Subject Re: SetVariable
Date
Msg-id 00e101c36d8d$f1580640$152aa8c0@GMENDOLA2
Whole thread Raw
In response to SetVariable  ("Mendola Gaetano" <mendola@bigfoot.com>)
List pgsql-hackers
Just a follow up, 
is it better to give a patch for this kind of stuff ?

Regards
Gaetano Mendola

""Mendola Gaetano"" <mendola@bigfoot.com> wrote:
> 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
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
> 



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Nasty problem in hash indexes
Next
From: "Mendola Gaetano"
Date:
Subject: Code revision