[Thunar-workers] CVS: design/analysis/mime dump-globs-by-type.c, 1.3, 1.4

Benedikt Meurer benny at xfce.org
Sun Mar 27 22:18:27 CEST 2005


Update of /var/cvs/thunar/design/analysis/mime
In directory espresso.foo-projects.org:/tmp/cvs-serv28806/mime

Modified Files:
	dump-globs-by-type.c 
Log Message:
2005-03-27	Benedikt Meurer <benny at xfce.org>

	* mime/dump-globs-by-type.c(main): Also calculate the number of bytes
	  required to store the Literal Patterns in a memory chunk.




Index: dump-globs-by-type.c
===================================================================
RCS file: /var/cvs/thunar/design/analysis/mime/dump-globs-by-type.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dump-globs-by-type.c	27 Mar 2005 19:42:40 -0000	1.3
+++ dump-globs-by-type.c	27 Mar 2005 20:18:25 -0000	1.4
@@ -196,24 +196,44 @@
       g_print ("\n");
     }
 
-  guint count_nodes = 0;
-  const gchar *previous_pattern = "";
-  for (lp = loader.parsed_patterns[PATTERN_SIMPLE]; lp != NULL; lp = lp->next)
+  /* calculate memory consumed by literal patterns */
     {
-      pp = lp->data;
-
-      int length = strlen (pp->pattern);
+      guint bytes = 0;
+      for (lp = loader.parsed_patterns[PATTERN_LITERAL]; lp != NULL; lp = lp->next)
+        {
+          pp = lp->data;
 
-      int i;
-      for (i = 0; pp->pattern[i] != '\0' && pp->pattern[i] == previous_pattern[i]; ++i)
-        ;
+          /* size required for the two pointers */
+          bytes += sizeof (void *) + sizeof (void *);
 
-      count_nodes += length - i;
+          /* size required for the pattern string (including the padding) */
+          bytes += ((strlen (pp->pattern) + 1 + 3) / 4) * 4;
+        }
 
-      previous_pattern = pp->pattern;
+      g_print ("Number of types for the Literal Patterns: %u Bytes\n\n", bytes);
     }
 
-  g_print ("Number of nodes for Simple Patterns: %d (%d Bytes)\n\n", count_nodes, count_nodes * 16);
+  /* calculate the number of nodes for simple patterns */
+    {
+      guint count_nodes = 0;
+      const gchar *previous_pattern = "";
+      for (lp = loader.parsed_patterns[PATTERN_SIMPLE]; lp != NULL; lp = lp->next)
+        {
+          pp = lp->data;
+
+          int length = strlen (pp->pattern);
+
+          int i;
+          for (i = 0; pp->pattern[i] != '\0' && pp->pattern[i] == previous_pattern[i]; ++i)
+            ;
+
+          count_nodes += length - i;
+
+          previous_pattern = pp->pattern;
+        }
+
+      g_print ("Number of nodes for Simple Patterns: %u (%u Bytes)\n\n", count_nodes, count_nodes * 16);
+    }
 
   return 0;
 }




More information about the Thunar-workers mailing list