Commit 4fdbeeebe0f537a903d81046a1efc6a69ddf04bb

Authored by Loic Dachary
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>
Examples/.gitignore
... ... @@ -5,4 +5,5 @@
5 5 /liberation_[0-9][0-9]
6 6 /reed_sol_[0-9][0-9]
7 7 /reed_sol_test_gf
8   -/reed_sol_time_gf
9 8 \ No newline at end of file
  9 +/reed_sol_time_gf
  10 +/test_galois
... ...
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
... ...
Examples/test_galois.c 0 → 100644
... ... @@ -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
... ... @@ -47,6 +47,7 @@ extern &quot;C&quot; {
47 47 #endif
48 48  
49 49 extern int galois_init_default_field(int w);
  50 +extern int galois_uninit_field(int w);
50 51 extern void galois_change_technique(gf_t *gf, int w);
51 52  
52 53 extern int galois_single_multiply(int a, int b, int w);
... ...
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) {
... ...