- fix
[oweals/gnunet.git] / src / regex / perf-regex.c
index 2571419d76a9e92868c52b04effafa7e1d987166..4e339d2282193c6b3a7c6f7dabefa28d09bbc528 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/regex/prof-regex.c
+ * @file src/regex/perf-regex.c
  * @brief Test how long it takes to create a automaton from a string regex.
  * @author Bartlomiej Polot
  */
@@ -38,7 +38,10 @@ usage(void)
 }
 
 /**
- * The main function to obtain peer information.
+ * The main function of the regex performace test.
+ * 
+ * Read a set of regex from a file, combine them and create a DFA from the
+ * resulting combined regex.
  *
  * @param argc number of arguments from the command line
  * @param argv command line arguments
@@ -51,8 +54,6 @@ main (int argc, char *const *argv)
   char **regexes;
   char *buffer;
   char *regex;
-  unsigned int nr;
-  unsigned int i;
   int compression;
   long size;
 
@@ -65,21 +66,24 @@ main (int argc, char *const *argv)
   }
   regexes = GNUNET_REGEX_read_from_file (argv[1]);
 
+  if (NULL == regexes)
+  {
+    usage();
+    return 2;
+  }
   buffer = GNUNET_REGEX_combine (regexes);
 
   GNUNET_asprintf (&regex, "GNVPN-0001-PAD(%s)(0|1)*", buffer);
   size = strlen (regex);
 
-  // fprintf (stderr, "Combined regex (%ld bytes):\n%s\n", size, regex);
+  fprintf (stderr, "Combined regex (%ld bytes):\n%s\n", size, regex);
   //   return 0;
 
   compression = atoi (argv[2]);
   dfa = GNUNET_REGEX_construct_dfa (regex, size, compression);
   GNUNET_REGEX_automaton_destroy (dfa);
   GNUNET_free (buffer);
-  for (i=0;i<nr;i++)
-    GNUNET_free_non_null (regexes[i]);
-  GNUNET_array_grow (regexes, nr, 0);
+  GNUNET_REGEX_free_from_file (regexes);
   return 0;
 }