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



On Wed, 2006-07-26 at 04:11 -0600, Veerapuram Varadhan wrote:
> On Thu, 2006-07-20 at 20:30 +0000, Philip Van Hoof wrote:

> Its not a good practice to *free* parameter-value inside token_add.

Correct. It's however more or less the same as the current
camel_pstring_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);

This creates memory segmentation as the only time the string needs to be
freed, is when it's already found in the tokens table.

This way, it will always be freed. That's the reason why the free
happens in token_add (and why token_add is a static or implementation
detail of camel-folder-summary.c).


-- 
Philip Van Hoof, software developer at x-tend 
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
work: vanhoof at x-tend dot be 
http://www.pvanhoof.be - http://www.x-tend.be




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