Commit 4fdbeeebe0f537a903d81046a1efc6a69ddf04bb
1 parent
21de9838
Exists in
master
define galois_uninit_field
To free resources allocated by galois_init_default_field. Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Showing
5 changed files
with
44 additions
and
2 deletions
Show diff stats
Examples/.gitignore
Examples/Makefile.am
... | ... | @@ -25,10 +25,15 @@ bin_PROGRAMS = jerasure_01 \ |
25 | 25 | encoder \ |
26 | 26 | decoder |
27 | 27 | |
28 | -TESTS=test_all_gfs.sh | |
28 | +check_PROGRAMS = | |
29 | + | |
30 | +TESTS=test_all_gfs.sh $(check_PROGRAMS) | |
29 | 31 | |
30 | 32 | dist_noinst_SCRIPTS = test_all_gfs.sh time_all_gfs_argv_init.sh |
31 | 33 | |
34 | +test_galois_SOURCES = test_galois.c | |
35 | +check_PROGRAMS += test_galois | |
36 | + | |
32 | 37 | jerasure_01_SOURCES = jerasure_01.c |
33 | 38 | jerasure_02_SOURCES = jerasure_02.c |
34 | 39 | jerasure_03_SOURCES = jerasure_03.c | ... | ... |
... | ... | @@ -0,0 +1,23 @@ |
1 | +#include <assert.h> | |
2 | +#include "galois.h" | |
3 | + | |
4 | +int main(int argc, char **argv) | |
5 | +{ | |
6 | + assert(galois_init_default_field(4) == 0); | |
7 | + assert(galois_uninit_field(4) == 0); | |
8 | + assert(galois_init_default_field(4) == 0); | |
9 | + assert(galois_uninit_field(4) == 0); | |
10 | + | |
11 | + assert(galois_init_default_field(8) == 0); | |
12 | + assert(galois_uninit_field(8) == 0); | |
13 | + assert(galois_init_default_field(8) == 0); | |
14 | + assert(galois_uninit_field(8) == 0); | |
15 | + | |
16 | + return 0; | |
17 | +} | |
18 | +/* | |
19 | + * Local Variables: | |
20 | + * compile-command: "make test_galois && | |
21 | + * libtool --mode=execute valgrind --tool=memcheck --leak-check=full ./test_galois" | |
22 | + * End: | |
23 | + */ | ... | ... |
include/galois.h
src/galois.c
... | ... | @@ -181,6 +181,18 @@ int galois_init_default_field(int w) |
181 | 181 | return 0; |
182 | 182 | } |
183 | 183 | |
184 | +int galois_uninit_field(int w) | |
185 | +{ | |
186 | + int ret = 0; | |
187 | + if (gfp_array[w] != NULL) { | |
188 | + int recursive = 1; | |
189 | + ret = gf_free(gfp_array[w], recursive); | |
190 | + free(gfp_array[w]); | |
191 | + gfp_array[w] = NULL; | |
192 | + } | |
193 | + return ret; | |
194 | +} | |
195 | + | |
184 | 196 | static void galois_init(int w) |
185 | 197 | { |
186 | 198 | if (w <= 0 || w > 32) { | ... | ... |