]> Savannah Git Hosting - gnulib.git/commitdiff
uninorm tests: Free allocated memory.
authorBruno Haible <bruno@clisp.org>
Sun, 10 Mar 2019 14:14:01 +0000 (15:14 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 10 Mar 2019 14:14:01 +0000 (15:14 +0100)
* tests/uninorm/test-u32-normalize-big.h
(struct normalization_test_file): Remove 'const' from allocated member.
(free_normalization_test_file): New declaration.
* tests/uninorm/test-u32-normalize-big.c (test_other): Free allocated
memory.
(free_normalization_test_file): New function.
* tests/uninorm/test-u32-nfc-big.c (main): Free allocated
'struct normalization_test_file' contents.
* tests/uninorm/test-u32-nfd-big.c (main): Likewise.
* tests/uninorm/test-u32-nfkc-big.c (main): Likewise.
* tests/uninorm/test-u32-nfkd-big.c (main): Likewise.

ChangeLog
tests/uninorm/test-u32-nfc-big.c
tests/uninorm/test-u32-nfd-big.c
tests/uninorm/test-u32-nfkc-big.c
tests/uninorm/test-u32-nfkd-big.c
tests/uninorm/test-u32-normalize-big.c
tests/uninorm/test-u32-normalize-big.h

index 5ddd3b6e00ef6723599ba1b96fd8591c81c57650..9678f430d083d101a44f3ec6e0a55a12706db9c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2019-03-10  Bruno Haible  <bruno@clisp.org>
+
+       uninorm tests: Free allocated memory.
+       * tests/uninorm/test-u32-normalize-big.h
+       (struct normalization_test_file): Remove 'const' from allocated member.
+       (free_normalization_test_file): New declaration.
+       * tests/uninorm/test-u32-normalize-big.c (test_other): Free allocated
+       memory.
+       (free_normalization_test_file): New function.
+       * tests/uninorm/test-u32-nfc-big.c (main): Free allocated
+       'struct normalization_test_file' contents.
+       * tests/uninorm/test-u32-nfd-big.c (main): Likewise.
+       * tests/uninorm/test-u32-nfkc-big.c (main): Likewise.
+       * tests/uninorm/test-u32-nfkd-big.c (main): Likewise.
+
 2019-03-10  Bruno Haible  <bruno@clisp.org>
 
        di-set: Fix memory leak.
index fe8de41f1f8d6a6cc46da4b80a807d01f982f990..03dd630e790c351972deec51184a25eaf28fe13b 100644 (file)
@@ -106,6 +106,8 @@ main (int argc, char *argv[])
   test_specific (&file, check);
   test_other (&file, UNINORM_NFC);
 
+  free_normalization_test_file (&file);
+
   return 0;
 }
 
index 30c4f7b8ee9f40dcaced1ff219c4437f1064c9d7..c53ee8c93db040e9f975a6914594248140c5ed5b 100644 (file)
@@ -106,6 +106,8 @@ main (int argc, char *argv[])
   test_specific (&file, check);
   test_other (&file, UNINORM_NFD);
 
+  free_normalization_test_file (&file);
+
   return 0;
 }
 
index 09027db8e4788fe7bc3d11c5cd6c9fb08688a22b..709d023faf23e8e67c02cdc96c178c5b6f4f9c9e 100644 (file)
@@ -103,6 +103,8 @@ main (int argc, char *argv[])
   test_specific (&file, check);
   test_other (&file, UNINORM_NFKC);
 
+  free_normalization_test_file (&file);
+
   return 0;
 }
 
index 55d8ed84a0c828f83167ee558269108521135a4b..7fce8bc1103d7632c2e4cd88bb3f7657040b93b2 100644 (file)
@@ -103,6 +103,8 @@ main (int argc, char *argv[])
   test_specific (&file, check);
   test_other (&file, UNINORM_NFKD);
 
+  free_normalization_test_file (&file);
+
   return 0;
 }
 
index bec8b5d408c887ba39cece5da21f9a3621e99d99..7c7d04d6c26f0603db08ffb80a0e1043769a9222 100644 (file)
@@ -297,8 +297,34 @@ test_other (const struct normalization_test_file *file, uninorm_t nf)
           input[0] = uc;
           result = u32_normalize (nf, input, 1, NULL, &length);
           ASSERT (result != NULL && length == 1 && result[0] == uc);
+
+          free (result);
+        }
+    }
+}
+
+void
+free_normalization_test_file (struct normalization_test_file *file)
+{
+  size_t part_index;
+
+  for (part_index = 0; part_index < 4; part_index++)
+    {
+      const struct normalization_test_part *p = &file->parts[part_index];
+      size_t line_index;
+
+      for (line_index = 0; line_index < p->lines_length; line_index++)
+        {
+          const struct normalization_test_line *l = &p->lines[line_index];
+          size_t sequence_index;
+
+          for (sequence_index = 0; sequence_index < 5; sequence_index++)
+            free (l->sequences[sequence_index]);
         }
+      free (p->lines);
     }
+  free (file->part1_c1_sorted);
+  free (file->filename);
 }
 
 #endif
index e0fe75c04b6e9bdcecb01e422990cfff6341b40a..ed1366599b3087470327776023c4196d6d6806db 100644 (file)
@@ -48,7 +48,7 @@ struct normalization_test_file
      sentinel value of 0x110000 at the end.  */
   ucs4_t *part1_c1_sorted;
   /* The filename of the NormalizationTest.txt file.  */
-  const char *filename;
+  char *filename;
 };
 
 /* Read the NormalizationTest.txt file and return its contents.  */
@@ -68,3 +68,7 @@ extern void
 /* Perform the second compliance test.  */
 extern void
        test_other (const struct normalization_test_file *file, uninorm_t nf);
+
+/* Free the representation of the NormalizationTest.txt file.  */
+extern void
+       free_normalization_test_file (struct normalization_test_file *file);