Re: [Nautilus-list] [PATCH]: memory leak fix.
- From: Yoann Vandoorselaere <yoann mandrakesoft com>
- To: Darin Adler <darin bentspoon com>
- Cc: nautilus-list lists eazel com
- Subject: Re: [Nautilus-list] [PATCH]: memory leak fix.
- Date: 28 Aug 2001 00:15:41 +0200
On 27 Aug 2001 14:34:48 -0700, Darin Adler wrote:
> On Monday, August 27, 2001, at 01:27 PM, Yoann Vandoorselaere wrote:
>
> > here is a patch that fix several leak, and some unneeded operations :
> > can I commit ?
>
> You need to fix some small things first.
[...]
> After this change, the code can call xmlFree on the string constant "C".
> Please fix that. Also, please use a space after the name of a function
> before the parameter list when changing Nautilus source code. Use "xmlFree
> (x)", not "xmlFree(x)".
oops, /me very tired.
[...]
> > BTW, shouldn't refresh_stored_viewers() in nautilus-window.c take care
> > of freeing each node->data ? Or does
> > gnome_vfs_mime_component_list_free() take care of it ?
>
> Yes, it does. But you shouldn't have to ask. You have the source code to
> gnome_vfs_mime_component_list_free, so you can check for yourself.
Yes, I should have... I'm very, very, tired.
I didn't even thought about it. Attached is the new patch, commit ok ?
--
Yoann Vandoorselaere
http://prelude.sourceforge.net
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.4739
diff -u -p -r1.4739 ChangeLog
--- ChangeLog 2001/08/27 15:18:29 1.4739
+++ ChangeLog 2001/08/27 22:12:08
@@ -1,5 +1,15 @@
2001-08-27 Yoann Vandoorselaere <yoann mandrakesoft com>
+ * libnautilus-private/nautilus-link.c (nautilus_link_local_get_image_uri):
+ avoid un-needed string copy.
+
+ * components/help/hyperbola-filefmt.c (locale_score):
+ free return of xmlGetProp on return. Do not use a char pointer
+ to point on the returned value, use an xmlChar pointer.
+
+ * libnautilus-private/nautilus-link.c (nautilus_link_local_get_link_type):
+ Free the value returned by local_get_root_property.
+
* src/nautilus-switchable-search-bar.c (nautilus_switchable_search_bar_new):
Don't leak a GtkBox.
Index: components/help/hyperbola-filefmt.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/help/hyperbola-filefmt.c,v
retrieving revision 1.35
diff -u -p -r1.35 hyperbola-filefmt.c
--- components/help/hyperbola-filefmt.c 2001/05/11 01:30:26 1.35
+++ components/help/hyperbola-filefmt.c 2001/08/27 22:12:09
@@ -1538,6 +1538,24 @@ fmt_toplevel_add_doc (HyperbolaDocTree *
}
}
+
+static int
+get_locale_score (GList *li, xmlChar *locale)
+{
+ int score = 0;
+
+ for (li; li != NULL; li = li->next) {
+ if (strcmp (locale, (char *) li->data) == 0)
+ return score;
+
+ score++;
+ }
+
+ return -1;
+}
+
+
+
/* returns -1 on invalid locale (not found), or the position
* in the locale list. the lower the position the better, that
* is, the lower number should get precedence */
@@ -1545,7 +1563,7 @@ static int
locale_score (GList *locales, xmlNode *doc_node)
{
GList *li;
- char *locale;
+ xmlChar *locale;
int score;
if (doc_node == NULL)
@@ -1554,18 +1572,13 @@ locale_score (GList *locales, xmlNode *d
locale = xmlGetProp (doc_node, "locale");
if (locale == NULL) {
locale = "C";
- }
-
- score = 0;
- for (li = locales; li != NULL; li = li->next) {
- if (strcmp (locale, (char *) li->data) == 0) {
- return score;
- }
+ score = get_locale_score (locales, locale);
+ } else {
+ score = get_locale_score (locales, locale);
+ xmlFree (locale);
+ }
- score++;
- }
-
- return -1;
+ return score;
}
/* do we want to use new_doc rather then current_doc. That is, is new_doc
Index: libnautilus-private/nautilus-link.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link.c,v
retrieving revision 1.58
diff -u -p -r1.58 nautilus-link.c
--- libnautilus-private/nautilus-link.c 2001/08/27 15:18:31 1.58
+++ libnautilus-private/nautilus-link.c 2001/08/27 22:12:10
@@ -437,11 +437,10 @@ nautilus_link_local_get_image_uri (const
/* load it asynchronously through gnome-vfs */
info = g_new0 (NautilusLinkIconNotificationInfo, 1);
info->link_uri = gnome_vfs_get_uri_from_local_path (path);
- info->file_path = g_strdup (local_path);
+ info->file_path = local_path;
eel_read_entire_file_async (icon_uri, icon_read_done_callback, info);
g_free (icon_uri);
- g_free (local_path);
return NULL; /* return NULL since the icon is still loading - it will get correctly set by the callback */
}
@@ -459,7 +458,14 @@ nautilus_link_local_get_link_uri (const
NautilusLinkType
nautilus_link_local_get_link_type (const char *path)
{
- return get_link_type (local_get_root_property (path, "nautilus_link"));
+ char *property;
+ NautilusLinkType type;
+
+ property = local_get_root_property (path, "nautilus_link");
+ type = get_link_type (property);
+ g_free (property);
+
+ return type;
}
/* FIXME bugzilla.eazel.com 2495:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]