Skip to content

Commit 4fdbeee

Browse files
author
Loic Dachary
committed
define galois_uninit_field
To free resources allocated by galois_init_default_field. Signed-off-by: Loic Dachary <[email protected]>
1 parent 21de983 commit 4fdbeee

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed

Examples/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
/liberation_[0-9][0-9]
66
/reed_sol_[0-9][0-9]
77
/reed_sol_test_gf
8-
/reed_sol_time_gf
8+
/reed_sol_time_gf
9+
/test_galois

Examples/Makefile.am

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,15 @@ bin_PROGRAMS = jerasure_01 \
2525
encoder \
2626
decoder
2727

28-
TESTS=test_all_gfs.sh
28+
check_PROGRAMS =
29+
30+
TESTS=test_all_gfs.sh $(check_PROGRAMS)
2931

3032
dist_noinst_SCRIPTS = test_all_gfs.sh time_all_gfs_argv_init.sh
3133

34+
test_galois_SOURCES = test_galois.c
35+
check_PROGRAMS += test_galois
36+
3237
jerasure_01_SOURCES = jerasure_01.c
3338
jerasure_02_SOURCES = jerasure_02.c
3439
jerasure_03_SOURCES = jerasure_03.c

Examples/test_galois.c

+23
Original file line numberDiff line numberDiff line change
@@ -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

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ extern "C" {
4747
#endif
4848

4949
extern int galois_init_default_field(int w);
50+
extern int galois_uninit_field(int w);
5051
extern void galois_change_technique(gf_t *gf, int w);
5152

5253
extern int galois_single_multiply(int a, int b, int w);

src/galois.c

+12
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,18 @@ int galois_init_default_field(int w)
181181
return 0;
182182
}
183183

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+
184196
static void galois_init(int w)
185197
{
186198
if (w <= 0 || w > 32) {

0 commit comments

Comments
 (0)