Re: [evolution-patches] Fix for "agressive" memory segmentation

Philip Van Hoof <[email protected]>
Newsgroups gmane.comp.gnome.evolution.patches,gmane.comp.gnome.evolution.devel
Message-ID <1152221761.5374.46.camel__41637.4429282316$1152273799$gmane$org@localhost.localdomain>
On Thu, 2006-07-06 at 15:36 -0400, Jeffrey Stedfast wrote:
> On Thu, 2006-07-06 at 21:32 +0200, Philip Van Hoof wrote:
> > On Thu, 2006-07-06 at 15:18 -0400, Jeffrey Stedfast wrote:
> > > For some strange reason I thought the pstring stuff already did that,
> > > oops. I guess I was thinking of similar code I wrote a few years back
> > > for another project...
> > > 
> > > This patch does it the way I had done it in another project of mine
> > 
> > Yours looks a little bit more clean in naming and stuff like that. It
> > probably does more or less the same? So I'd say commit one of the two?
> 
> yea, it's basically the same as what you did

Err. I don't want to disappoint you. But measuring your implementation
shows that you are allocated three megabytes more data than the original
one.

Mine didn't do that because I freed the str in the first if-block.

The attached patch fixes it. The attached valgrind reports show it.

Ok to commit this? Will you commit it?

 
-- 
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

_______________________________________________
Evolution-hackers mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-hackers
fix.diff (text/x-patch, 902 B)
? camel-mime-tables.c
Index: camel-string-utils.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-string-utils.c,v
retrieving revision 1.6
diff -u -r1.6 camel-string-utils.c
--- camel-string-utils.c	6 Jul 2006 19:43:47 -0000	1.6
+++ camel-string-utils.c	6 Jul 2006 21:34:32 -0000
@@ -164,10 +164,10 @@
 	char *pstr;
 	int count;
 	
-	if (s == NULL)
+	if (str == NULL)
 		return NULL;
 	
-	if (s[0] == '\0') {
+	if (str[0] == '\0') {
 		if (own)
 			g_free (str);
 		return "";
@@ -180,6 +180,7 @@
 	if (g_hash_table_lookup_extended (pstring_table, str, (void **) &pstr, &pcount)) {
 		count = GPOINTER_TO_INT (pcount) + 1;
 		g_hash_table_insert (pstring_table, pstr, GINT_TO_POINTER (count));
+		g_free (str);
 	} else {
 		pstr = own ? str : g_strdup (str);
 		g_hash_table_insert (pstring_table, pstr, GINT_TO_POINTER (1));
valgrind.tar.gz (application/x-compressed-tar, 68.5 KB) - not displayed
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.