Re: Memory improvement for the tokens in camel_folder_summary.c

"Veerapuram Varadhan" <[email protected]>
Newsgroups gmane.comp.gnome.evolution.patches
Message-ID <[email protected]>
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
_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.