Re: [Nautilus-list] [PATCH]: memory leak fix.



On Monday, August 27, 2001, at 03:15  PM, Yoann Vandoorselaere wrote:

Attached is the new patch, commit ok ?

Looks fine to commit. Just a few tiny nits to pick.

+get_locale_score (GList *li, xmlChar *locale)

I would have made the locale parameter be const xmlChar *.

+	for (li; li != NULL; li = li->next) {
+		if (strcmp (locale, (char *) li->data) == 0)
+                        return score;
+
+		score++;
+	}

Nautilus coding style requires { } around the body of the if statement.

 	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);
+        }

There are advantages to just doing:

    score = get_locale_score (locales, "C");

instead of doing 'locale = "C"'.

    -- Darin




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