[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23960 - gnunet/src/regex
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23960 - gnunet/src/regex |
Date: |
Sun, 23 Sep 2012 18:56:46 +0200 |
Author: szengel
Date: 2012-09-23 18:56:46 +0200 (Sun, 23 Sep 2012)
New Revision: 23960
Modified:
gnunet/src/regex/regex_internal.h
gnunet/src/regex/test_regex_iterate_api.c
Log:
refactoring
Modified: gnunet/src/regex/regex_internal.h
===================================================================
--- gnunet/src/regex/regex_internal.h 2012-09-23 16:24:28 UTC (rev 23959)
+++ gnunet/src/regex/regex_internal.h 2012-09-23 16:56:46 UTC (rev 23960)
@@ -378,9 +378,9 @@
* @param stride_len length of the strides.
*/
void
-GNUNET_REGEX_add_multi_strides_to_dfa (struct GNUNET_REGEX_Context *regex_ctx,
- struct GNUNET_REGEX_Automaton *dfa,
- const unsigned int stride_len);
+GNUNET_REGEX_dfa_add_multi_strides (struct GNUNET_REGEX_Context *regex_ctx,
+ struct GNUNET_REGEX_Automaton *dfa,
+ const unsigned int stride_len);
/**
Modified: gnunet/src/regex/test_regex_iterate_api.c
===================================================================
--- gnunet/src/regex/test_regex_iterate_api.c 2012-09-23 16:24:28 UTC (rev
23959)
+++ gnunet/src/regex/test_regex_iterate_api.c 2012-09-23 16:56:46 UTC (rev
23960)
@@ -30,13 +30,20 @@
static unsigned int transition_counter;
+struct IteratorContext
+{
+ int error;
+ int should_save_graph;
+ FILE *graph_file;
+};
+
void
key_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof,
int accepting, unsigned int num_edges,
const struct GNUNET_REGEX_Edge *edges)
{
unsigned int i;
- int *error = cls;
+ struct IteratorContext *ctx = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iterating... (accepting: %i)\n",
accepting);
@@ -54,7 +61,7 @@
i, edges[i].label, GNUNET_h2s (&edges[i].destination));
}
- *error += (GNUNET_OK == GNUNET_REGEX_check_proof (proof, key)) ? 0 : 1;
+ ctx->error += (GNUNET_OK == GNUNET_REGEX_check_proof (proof, key)) ? 0 : 1;
}
int
@@ -69,9 +76,10 @@
NULL);
int error;
- int i;
struct GNUNET_REGEX_Automaton *dfa;
+ unsigned int i;
unsigned int num_transitions;
+ struct IteratorContext ctx = { 0, 0, NULL };
error = 0;
@@ -99,7 +107,7 @@
{
transition_counter = 0;
dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
- GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error);
+ GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx);
num_transitions = GNUNET_REGEX_get_transition_count (dfa);
if (transition_counter != num_transitions)
{
@@ -113,10 +121,12 @@
for (i = 0; i < 17; i++)
{
dfa = GNUNET_REGEX_construct_dfa (regex[i], strlen (regex[i]));
- GNUNET_REGEX_add_multi_strides_to_dfa (NULL, dfa, 2);
- GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &error);
+ GNUNET_REGEX_dfa_add_multi_strides (NULL, dfa, 2);
+ GNUNET_REGEX_iterate_all_edges (dfa, key_iterator, &ctx);
GNUNET_REGEX_automaton_destroy (dfa);
}
+ error += ctx.error;
+
return error;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23960 - gnunet/src/regex,
gnunet <=