define galois_uninit_field
To free resources allocated by galois_init_default_field. Signed-off-by: Loic Dachary <loic-201408@dachary.org>master
parent
21de983833
commit
4fdbeeebe0
|
@ -6,3 +6,4 @@
|
|||
/reed_sol_[0-9][0-9]
|
||||
/reed_sol_test_gf
|
||||
/reed_sol_time_gf
|
||||
/test_galois
|
||||
|
|
|
@ -25,10 +25,15 @@ bin_PROGRAMS = jerasure_01 \
|
|||
encoder \
|
||||
decoder
|
||||
|
||||
TESTS=test_all_gfs.sh
|
||||
check_PROGRAMS =
|
||||
|
||||
TESTS=test_all_gfs.sh $(check_PROGRAMS)
|
||||
|
||||
dist_noinst_SCRIPTS = test_all_gfs.sh time_all_gfs_argv_init.sh
|
||||
|
||||
test_galois_SOURCES = test_galois.c
|
||||
check_PROGRAMS += test_galois
|
||||
|
||||
jerasure_01_SOURCES = jerasure_01.c
|
||||
jerasure_02_SOURCES = jerasure_02.c
|
||||
jerasure_03_SOURCES = jerasure_03.c
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include <assert.h>
|
||||
#include "galois.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
assert(galois_init_default_field(4) == 0);
|
||||
assert(galois_uninit_field(4) == 0);
|
||||
assert(galois_init_default_field(4) == 0);
|
||||
assert(galois_uninit_field(4) == 0);
|
||||
|
||||
assert(galois_init_default_field(8) == 0);
|
||||
assert(galois_uninit_field(8) == 0);
|
||||
assert(galois_init_default_field(8) == 0);
|
||||
assert(galois_uninit_field(8) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* compile-command: "make test_galois &&
|
||||
* libtool --mode=execute valgrind --tool=memcheck --leak-check=full ./test_galois"
|
||||
* End:
|
||||
*/
|
|
@ -47,6 +47,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
extern int galois_init_default_field(int w);
|
||||
extern int galois_uninit_field(int w);
|
||||
extern void galois_change_technique(gf_t *gf, int w);
|
||||
|
||||
extern int galois_single_multiply(int a, int b, int w);
|
||||
|
|
12
src/galois.c
12
src/galois.c
|
@ -181,6 +181,18 @@ int galois_init_default_field(int w)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int galois_uninit_field(int w)
|
||||
{
|
||||
int ret = 0;
|
||||
if (gfp_array[w] != NULL) {
|
||||
int recursive = 1;
|
||||
ret = gf_free(gfp_array[w], recursive);
|
||||
free(gfp_array[w]);
|
||||
gfp_array[w] = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void galois_init(int w)
|
||||
{
|
||||
if (w <= 0 || w > 32) {
|
||||
|
|
Loading…
Reference in New Issue