diff options
| author | J08nY | 2017-02-28 17:59:14 +0100 |
|---|---|---|
| committer | J08nY | 2017-02-28 17:59:14 +0100 |
| commit | c1730ad531219bcfbefe5ed7525c9862ee6af281 (patch) | |
| tree | a36ff943a9bed0a5b88a64b367d73e2ebedcd3ec /src | |
| parent | a6d27df32cba91c90c7f936b148ab13c02b745ac (diff) | |
| download | ecgen-c1730ad531219bcfbefe5ed7525c9862ee6af281.tar.gz ecgen-c1730ad531219bcfbefe5ed7525c9862ee6af281.tar.zst ecgen-c1730ad531219bcfbefe5ed7525c9862ee6af281.zip | |
added stack rewind code to exhaustive_gen
Diffstat (limited to 'src')
| -rw-r--r-- | src/exhaustive/exhaustive.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index a405ec1..2367058 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -65,15 +65,32 @@ void exhaustive_vinit(arg_t *argss[], config_t *config) { } int exhaustive_gen(curve_t *curve, config_t *config, gen_t generators[], - arg_t *argss[], int start_offset, int end_offset) { + arg_t *argss[], int start_offset, int end_offset) { + if (start_offset == end_offset) { + return 1; + } + if (start_offset > end_offset) { + return 0; + } + pari_sp tops[end_offset - start_offset]; + int state = start_offset; - while (state != end_offset) { + while (state < end_offset) { + tops[state - start_offset] = avma; + int diff = - generators[state](curve, config, argss ? argss[state] : NULL); + generators[state](curve, config, argss ? argss[state] : NULL); + state += diff; + if (diff == INT_MIN) { fprintf(stderr, "Error generating a curve. %i\n", state); return 0; } + + if (diff <= 0) { + avma = tops[state - start_offset]; + } + if (config->verbose) { if (diff > 0) { fprintf(debug, "+"); @@ -84,7 +101,7 @@ int exhaustive_gen(curve_t *curve, config_t *config, gen_t generators[], } fflush(debug); } - state += diff; + } if (config->verbose) fprintf(debug, "\n"); @@ -104,7 +121,7 @@ int exhaustive_do(config_t *cfg) { curve_t *curve = curve_new(); if (!exhaustive_gen(curve, cfg, generators, argss, OFFSET_SEED, - OFFSET_END)) { + OFFSET_END)) { curve_free(&curve); return 1; } |
