diff options
| author | J08nY | 2017-09-30 16:34:50 +0200 |
|---|---|---|
| committer | J08nY | 2017-09-30 16:34:50 +0200 |
| commit | 64ccc59f390cb3a3a2f0347c8807fe4091bb5cd8 (patch) | |
| tree | 6dfe8da7776c9ef549fc64824cf7a767c048eb3c /src/exhaustive/exhaustive.c | |
| parent | 381ccc4beaf3879606ca33fb385526c8fd8d8fcf (diff) | |
| download | ecgen-64ccc59f390cb3a3a2f0347c8807fe4091bb5cd8.tar.gz ecgen-64ccc59f390cb3a3a2f0347c8807fe4091bb5cd8.tar.zst ecgen-64ccc59f390cb3a3a2f0347c8807fe4091bb5cd8.zip | |
Add new/create/free funcs for malloced exhaustive_t.
Diffstat (limited to 'src/exhaustive/exhaustive.c')
| -rw-r--r-- | src/exhaustive/exhaustive.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/exhaustive/exhaustive.c b/src/exhaustive/exhaustive.c index 6c8c83d..623396e 100644 --- a/src/exhaustive/exhaustive.c +++ b/src/exhaustive/exhaustive.c @@ -3,7 +3,6 @@ * Copyright (C) 2017 J08nY */ #include "exhaustive.h" -#include <misc/types.h> #include "anomalous.h" #include "ansi.h" #include "check.h" @@ -17,6 +16,39 @@ #include "io/output.h" #include "util/memory.h" +exhaustive_t *exhaustive_new(void) { return try_calloc(sizeof(exhaustive_t)); } + +exhaustive_t *exhaustive_create(gen_f *generators, check_t **validators, + arg_t **argss, unroll_f *unrolls) { + exhaustive_t *result = exhaustive_new(); + result->generators = generators; + result->validators = validators; + result->argss = argss; + result->unrolls = unrolls; + return result; +} + +void exhaustive_clear(exhaustive_t *setup) { + if (setup->validators) { + for (size_t i = 0; i < OFFSET_END; ++i) { + check_free(&setup->validators[i]); + } + } + if (setup->argss) { + for (size_t i = 0; i < OFFSET_END; ++i) { + arg_free(&setup->argss[i]); + } + } +} + +void exhaustive_free(exhaustive_t **setup) { + if (*setup) { + exhaustive_clear(*setup); + try_free(*setup); + *setup = NULL; + } +} + static void exhaustive_ginit(gen_f *generators, const config_t *cfg) { if (cfg->seed_algo) { switch (cfg->seed_algo) { |
