r13597 tlsa - /trunk/libdom/src/core/element.c

netsurf at semichrome.net netsurf at semichrome.net
Sat Mar 24 15:25:46 GMT 2012


Author: tlsa
Date: Sat Mar 24 10:25:46 2012
New Revision: 13597

URL: http://source.netsurf-browser.org?rev=13597&view=rev
Log:
Split out destruction of element class cache.

Modified:
    trunk/libdom/src/core/element.c

Modified: trunk/libdom/src/core/element.c
URL: http://source.netsurf-browser.org/trunk/libdom/src/core/element.c?rev=13597&r1=13596&r2=13597&view=diff
==============================================================================
--- trunk/libdom/src/core/element.c (original)
+++ trunk/libdom/src/core/element.c Sat Mar 24 10:25:46 2012
@@ -331,6 +331,27 @@
 	} while (attr != list);
 
 	return new_list;
+}
+
+
+/**
+ * Destroy element's class cache
+ *
+ * \param ele  The element
+ */
+static void _dom_element_destroy_classes(struct dom_element *ele)
+{
+	/* Destroy the pre-separated class names */
+	if (ele->classes != NULL) {
+		unsigned int class;
+		for (class = 0; class < ele->n_classes; class++) {
+			lwc_string_unref(ele->classes[class]);
+		}
+		free(ele->classes);
+	}
+
+	ele->n_classes = 0;
+	ele->classes = NULL;
 }
 
 static dom_exception _dom_element_get_attr(struct dom_element *element,
@@ -495,13 +516,7 @@
 	}
 
 	/* Destroy the pre-separated class names */
-	if (ele->classes != NULL) {
-		unsigned int class;
-		for (class = 0; class < ele->n_classes; class++) {
-			lwc_string_unref(ele->classes[class]);
-		}
-		free(ele->classes);
-	}
+	_dom_element_destroy_classes(ele);
 
 	/* Finalise base class */
 	_dom_node_finalise(&ele->base);




More information about the netsurf-commits mailing list