libcroco r318 - in trunk: . src
- From: pjmoulder svn gnome org
- To: svn-commits-list gnome org
- Subject: libcroco r318 - in trunk: . src
- Date: Sun, 30 Mar 2008 14:02:34 +0100 (BST)
Author: pjmoulder
Date: Sun Mar 30 14:02:34 2008
New Revision: 318
URL: http://svn.gnome.org/viewvc/libcroco?rev=318&view=rev
Log:
minor: (cr_declaration_destroy): Simplify implementation (and assert that next/prev elements point to each other).
Modified:
trunk/ChangeLog
trunk/src/cr-declaration.c
Modified: trunk/src/cr-declaration.c
==============================================================================
--- trunk/src/cr-declaration.c (original)
+++ trunk/src/cr-declaration.c Sun Mar 30 14:02:34 2008
@@ -773,22 +773,19 @@
g_return_if_fail (a_this);
/*
- *Go get the tail of the list.
- *Meanwhile, free each property/value pair contained in the list.
+ * Go to the last element of the list.
*/
- for (cur = a_this; cur && cur->next; cur = cur->next) {
- if (cur->property) {
- cr_string_destroy (cur->property);
- cur->property = NULL;
- }
+ for (cur = a_this; cur->next; cur = cur->next)
+ g_assert (cur->next->prev == cur);
- if (cur->value) {
- cr_term_destroy (cur->value);
- cur->value = NULL;
- }
- }
+ /*
+ * Walk backward the list and free each "next" element.
+ * Meanwhile, free each property/value pair contained in the list.
+ */
+ for (; cur; cur = cur->prev) {
+ g_free (cur->next);
+ cur->next = NULL;
- if (cur) {
if (cur->property) {
cr_string_destroy (cur->property);
cur->property = NULL;
@@ -800,27 +797,5 @@
}
}
- /*in case the list contains only one element */
- if (cur && !cur->prev) {
- g_free (cur);
- return;
- }
-
- /*walk backward the list and free each "next" element */
- for (cur = cur->prev; cur && cur->prev; cur = cur->prev) {
- if (cur->next) {
- g_free (cur->next);
- cur->next = NULL;
- }
- }
-
- if (!cur)
- return;
-
- if (cur->next) {
- g_free (cur->next);
- cur->next = NULL;
- }
-
- g_free (cur);
+ g_free (a_this);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]