Re: [evolution-patches] CamelFolderInfo's with GSlice



On Fri, 2006-10-20 at 12:00 +0200, Philip Van Hoof wrote:

> This patch attempts to replace the many different ways of allocating a
> CamelFolderInfo with the gslice allocator.

It looks like the code assumed the malloc0() and not malloc(). I decided
to simply replace the allocs with a constructor func which will return a
g_slice_new0 this time.

I'm adding this one to the gslice tracker and marking the first one as
obsolete:

http://bugzilla.gnome.org/show_bug.cgi?id=363156

-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
blog: http://pvanhoof.be/blog
Index: camel/camel-store.c
===================================================================
--- camel/camel-store.c	(revision 1044)
+++ camel/camel-store.c	(working copy)
@@ -711,7 +711,7 @@
 		g_free (vinfo->uri);
 	} else {
 		/* There wasn't a Trash/Junk folder so create a new folder entry */
-		vinfo = g_new0 (CamelFolderInfo, 1);
+		vinfo = camel_folder_info_new ();
 		
 		g_assert(parent != NULL);
 		
@@ -856,6 +856,7 @@
 	;
 }
 
+
 /**
  * camel_folder_info_free:
  * @fi: a #CamelFolderInfo
@@ -871,10 +872,22 @@
 		g_free (fi->name);
 		g_free (fi->full_name);
 		g_free (fi->uri);
-		g_free (fi);
+		g_slice_free (CamelFolderInfo, fi);
 	}
 }
 
+
+/**
+ * camel_folder_info_new:
+ *
+ * Return value: a new empty CamelFolderInfo instance
+ **/
+CamelFolderInfo* 
+camel_folder_info_new (void)
+{
+	return g_slice_new0 (CamelFolderInfo);
+}
+
 static int
 folder_info_cmp (const void *ap, const void *bp)
 {
@@ -943,7 +956,7 @@
 				CamelURL *url;
 				char *sep;
 
-				pfi = g_new0 (CamelFolderInfo, 1);
+				pfi = camel_folder_info_new ();
 				if (short_names) {
 					pfi->name = strrchr (pname, separator);
 					if (pfi->name)
Index: camel/camel-store.h
===================================================================
--- camel/camel-store.h	(revision 1044)
+++ camel/camel-store.h	(working copy)
@@ -231,6 +231,8 @@
 void             camel_store_free_folder_info_nop  (CamelStore *store,
 						    CamelFolderInfo *fi);
 
+
+CamelFolderInfo *camel_folder_info_new             (void);
 void             camel_folder_info_free            (CamelFolderInfo *fi);
 CamelFolderInfo *camel_folder_info_build           (GPtrArray *folders,
 						    const char *namespace,
Index: camel/providers/pop3/camel-pop3-folder.c
===================================================================
--- camel/providers/pop3/camel-pop3-folder.c	(revision 1044)
+++ camel/providers/pop3/camel-pop3-folder.c	(working copy)
@@ -193,7 +193,7 @@
 		ret = camel_pop3_stream_line(stream, &line, &len);
 		if (ret>=0) {
 			if (sscanf((char *) line, "%u %u", &id, &size) == 2) {
-				fi = g_malloc0(sizeof(*fi));
+				fi = g_malloc0 (sizeof(*fi));
 				fi->size = size;
 				fi->id = id;
 				fi->index = ((CamelPOP3Folder *)folder)->uids->len;
Index: camel/providers/imap/camel-imap-store.c
===================================================================
--- camel/providers/imap/camel-imap-store.c	(revision 1044)
+++ camel/providers/imap/camel-imap-store.c	(working copy)
@@ -1037,8 +1037,8 @@
 	const char *name;
 	CamelFolderInfo *fi;
 
-	fi = g_malloc0(sizeof(*fi));
-
+	fi = camel_folder_info_new ();
+	
 	fi->full_name = g_strdup(folder_name);
 	fi->unread = -1;
 	fi->total = -1;
@@ -2405,7 +2405,8 @@
 
 	flags = (flags & ~CAMEL_FOLDER_SUBSCRIBED) | (si->info.flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED);
 
-	fi = g_new0 (CamelFolderInfo, 1);
+	fi = camel_folder_info_new ();
+	
 	fi->full_name = g_strdup(camel_store_info_path(imap_store->summary, si));
 	if (!g_ascii_strcasecmp(fi->full_name, "inbox")) {
 		flags |= CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_TYPE_INBOX;
Index: camel/providers/local/camel-local-store.c
===================================================================
--- camel/providers/local/camel-local-store.c	(revision 1044)
+++ camel/providers/local/camel-local-store.c	(working copy)
@@ -486,7 +486,7 @@
 	g_free (str);
 	g_free (name);
 	
-	fi = g_new0 (CamelFolderInfo, 1);
+	fi = camel_folder_info_new ();
 	fi->full_name = g_strdup (folder_name);
 	fi->name = g_path_get_basename (folder_name);
 	fi->uri = g_strdup_printf ("%s:%s#%s", ((CamelService *) store)->url->protocol,
Index: camel/providers/local/camel-spool-store.c
===================================================================
--- camel/providers/local/camel-spool-store.c	(revision 1044)
+++ camel/providers/local/camel-spool-store.c	(working copy)
@@ -276,7 +276,7 @@
 	else
 		name = full;
 
-	fi = g_malloc0(sizeof(*fi));
+	fi = camel_folder_info_new ();
 	url = camel_url_copy(((CamelService *)store)->url);
 	camel_url_set_fragment(url, full);
 	fi->uri = camel_url_to_string(url, 0);
Index: camel/providers/local/camel-mh-store.c
===================================================================
--- camel/providers/local/camel-mh-store.c	(revision 1044)
+++ camel/providers/local/camel-mh-store.c	(working copy)
@@ -358,7 +358,7 @@
 	camel_url_set_fragment (url, path);
 	
 	/* Build the folder info structure. */
-	fi = g_malloc0(sizeof(*fi));
+	fi = camel_folder_info_new ();
 	fi->uri = camel_url_to_string (url, 0);
 	fi->full_name = g_strdup(path);
 	fi->name = g_strdup(base?base+1:path);
Index: camel/providers/local/camel-mbox-store.c
===================================================================
--- camel/providers/local/camel-mbox-store.c	(revision 1044)
+++ camel/providers/local/camel-mbox-store.c	(working copy)
@@ -319,7 +319,7 @@
 	g_free(path);
 	g_free(name);
 	
-	fi = g_new0(CamelFolderInfo, 1);
+	fi = camel_folder_info_new ();
 	fi->full_name = g_strdup(folder_name);
 	fi->name = g_path_get_basename(folder_name);
 	fi->uri = g_strdup_printf("mbox:%s#%s",((CamelService *) store)->url->path, folder_name);
@@ -694,7 +694,7 @@
 				fi->flags &= ~CAMEL_FOLDER_NOSELECT;
 			}
 		} else {
-			fi = g_new0(CamelFolderInfo, 1);
+			fi = camel_folder_info_new ();
 			fi->parent = parent;
 			
 			camel_url_set_fragment (url, full_name);
@@ -803,7 +803,7 @@
 	url = camel_url_copy (((CamelService *) store)->url);
 	camel_url_set_fragment (url, top);
 	
-	fi = g_new0(CamelFolderInfo, 1);
+	fi = camel_folder_info_new ();
 	fi->parent = NULL;
 	fi->uri = camel_url_to_string (url, 0);
 	fi->name = basename;
Index: camel/providers/local/camel-local-folder.c
===================================================================
--- camel/providers/local/camel-local-folder.c	(revision 1044)
+++ camel/providers/local/camel-local-folder.c	(working copy)
@@ -309,7 +309,7 @@
 		url = camel_url_copy (((CamelService *) parent_store)->url);
 		camel_url_set_fragment (url, full_name);
 	
-		fi = g_new0 (CamelFolderInfo, 1);
+		fi = camel_folder_info_new ();
 		fi->full_name = g_strdup (full_name);
 		fi->name = g_strdup (name);
 		fi->uri = camel_url_to_string (url, 0);
Index: camel/providers/local/camel-maildir-store.c
===================================================================
--- camel/providers/local/camel-maildir-store.c	(revision 1044)
+++ camel/providers/local/camel-maildir-store.c	(working copy)
@@ -365,7 +365,7 @@
 	char *tmp, *cur, *new;
 	struct stat st;
 
-	fi = g_malloc0(sizeof(*fi));
+	fi = camel_folder_info_new ();
 	fi->full_name = g_strdup(full);
 	fi->name = g_strdup(name);
 	camel_url_set_fragment(url, fi->full_name);
Index: camel/camel-vee-store.c
===================================================================
--- camel/camel-vee-store.c	(revision 1044)
+++ camel/camel-vee-store.c	(working copy)
@@ -146,7 +146,7 @@
 	const char *tmp;
 	CamelURL *url;
 
-	fi = g_malloc0(sizeof(*fi));
+	fi = camel_folder_info_new ();
 	fi->full_name = g_strdup(name);
 	tmp = strrchr(name, '/');
 	if (tmp == NULL)


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