Re: [evolution-patches] Memory improvement for the tokens in camel_folder_summary.c



On Thu, 2006-07-20 at 20:30 +0000, Philip Van Hoof wrote:
> +
> +guint bytes;
> +static gchar* 
> +token_add (gchar *str)
> +{
> +       int i;
> +
> +       if (!str)
> +               return NULL;
> +
> +       for (i=0; i<tokens_len; i++)
> +               if (!strcmp (str, tokens[i]))
> +               {
> +                       g_free (str);
> +                       return tokens[i];
> +               }
Its not a good practice to *free* parameter-value inside token_add.

> +       ci->id = token_add (camel_header_msgid_decode
> (camel_header_raw_find (&h, "content-id", NULL)));
A better way would be, 

gchar *str = NULL;
str = camel_header_msgid_decode (camel_header_raw_find (&h,
"content-id", NULL));
ci->id = token_add (str);
g_free (str);

V. Varadhan

 Novell, Inc. 
Software for the Open Enterprise™
http://www.novell.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]