]> git-server-git.apps.pok.os.sepia.ceph.com Git - jerasure.git/commitdiff
define galois_uninit_field
authorLoic Dachary <loic@dachary.org>
Sat, 13 Sep 2014 21:15:57 +0000 (23:15 +0200)
committerLoic Dachary <loic@dachary.org>
Fri, 3 Oct 2014 17:08:44 +0000 (19:08 +0200)
To free resources allocated by galois_init_default_field.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Examples/.gitignore
Examples/Makefile.am
Examples/test_galois.c [new file with mode: 0644]
include/galois.h
src/galois.c

index 97bbded0e215bbe05ce7572eabdbe89886167959..b97ec5a22228eb2ce33c47879b31e34e865521a8 100644 (file)
@@ -5,4 +5,5 @@
 /liberation_[0-9][0-9]
 /reed_sol_[0-9][0-9]
 /reed_sol_test_gf
-/reed_sol_time_gf
\ No newline at end of file
+/reed_sol_time_gf
+/test_galois
index 9aa47809dc393b4cb01d97dc22b029387efe2626..9e20f1cd9ce3ed1b5d1f1555ec23122a7f6d9136 100644 (file)
@@ -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
diff --git a/Examples/test_galois.c b/Examples/test_galois.c
new file mode 100644 (file)
index 0000000..a913a77
--- /dev/null
@@ -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:
+ */
index b1e4652d7fb1b024f45b36aab85acabc21dd474b..78e6567d200c5d8ce9850f3e2b446773dad148c7 100644 (file)
@@ -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);
index 95d72bc34b503616de24f7bd65fd084e95bb3c07..6dc4282ed122b996185686531d7276349941f69a 100644 (file)
@@ -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) {