]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add cleanup to trainfromFiles and move RANDOM_segment_t declaration
authorJennifer Liu <jenniferliu620@fb.com>
Wed, 18 Jul 2018 17:40:13 +0000 (10:40 -0700)
committerJennifer Liu <jenniferliu620@fb.com>
Wed, 18 Jul 2018 17:40:13 +0000 (10:40 -0700)
contrib/randomDictBuilder/main.c
contrib/randomDictBuilder/random.c
contrib/randomDictBuilder/random.h

index 1f12c7a4bc329881137143b66532b2a38ae00129..36c4326b6aeb435df36ee2583553478601c4e1ff 100644 (file)
@@ -114,7 +114,7 @@ int RANDOM_trainFromFiles(const char* dictFileName, sampleInfo *info,
         if (ZDICT_isError(dictSize)) {
             DISPLAYLEVEL(1, "dictionary training failed : %s \n", ZDICT_getErrorName(dictSize));   /* should not happen */
             result = 1;
-            free(dictBuffer);
+            goto _cleanup;
         }
         /* save dict */
         DISPLAYLEVEL(2, "Save dictionary of size %u into file %s \n", (U32)dictSize, dictFileName);
@@ -122,6 +122,7 @@ int RANDOM_trainFromFiles(const char* dictFileName, sampleInfo *info,
     }
 
     /* clean up */
+_cleanup:
     free(dictBuffer);
     return result;
 }
index 34aec39eab3b2bf674ceff8d8009b91434600c70..5276bea96a56f4b165d0b60ac6d5f5f1560efd0c 100644 (file)
@@ -47,6 +47,15 @@ static size_t RANDOM_sum(const size_t *samplesSizes, unsigned nbSamples) {
 }
 
 
+/**
+ * A segment is an inclusive range in the source.
+ */
+typedef struct {
+  U32 begin;
+  U32 end;
+} RANDOM_segment_t;
+
+
 /**
  * Selects a random segment from totalSamplesSize - k + 1 possible segments
  */
index c3146f861c53ee854c901ee7b521ff9935090539..352775f950c4d9f664bc0b5f8c8f40268dc0bee9 100644 (file)
@@ -8,13 +8,6 @@
 #endif
 #include "zdict.h"
 
-/**
- * A segment is an inclusive range in the source.
- */
-typedef struct {
-  U32 begin;
-  U32 end;
-} RANDOM_segment_t;
 
 
 typedef struct {