[gtkhtml] Prefer G_N_ELEMENTS over sizeof calculations.



commit e316893200c3154e3f1715bf061a90d337cf26b2
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Oct 24 18:25:50 2009 -0400

    Prefer G_N_ELEMENTS over sizeof calculations.

 gtkhtml/htmltext.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/gtkhtml/htmltext.c b/gtkhtml/htmltext.c
index cb64bcc..2be78d5 100644
--- a/gtkhtml/htmltext.c
+++ b/gtkhtml/htmltext.c
@@ -3154,14 +3154,12 @@ static HTMLMagicInsertMatch mim [] = {
 	{ "[-_a-z0-9.'\\+]+ [-_a-z0-9 %=?]+", NULL, "mailto:"; }
 };
 
-#define MIM_N (sizeof (mim) / sizeof (mim [0]))
-
 void
 html_engine_init_magic_links (void)
 {
 	gint i;
 
-	for (i=0; i<MIM_N; i++) {
+	for (i = 0; i < G_N_ELEMENTS (mim); i++) {
 		mim [i].preg = g_new0 (regex_t, 1);
 		if (regcomp (mim [i].preg, mim [i].regex, REG_EXTENDED | REG_ICASE)) {
 			/* error */
@@ -3237,7 +3235,7 @@ html_text_magic_link (HTMLText *text, HTMLEngine *engine, guint offset)
 	}
 
 	if (exec) {
-		for (i=0; i<MIM_N; i++) {
+		for (i = 0; i < G_N_ELEMENTS (mim); i++) {
 			if (mim [i].preg && !regexec (mim [i].preg, str, 2, pmatch, 0)) {
 				paste_link (engine, text,
 					    g_utf8_pointer_to_offset (text->text, str + pmatch [0].rm_so),



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