From: Jennifer Liu Date: Wed, 18 Jul 2018 17:40:13 +0000 (-0700) Subject: Add cleanup to trainfromFiles and move RANDOM_segment_t declaration X-Git-Tag: v0.0.29~62^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52e7cf0e405ac6eb827322b607d094125646bbfb;p=thirdparty%2Fzstd.git Add cleanup to trainfromFiles and move RANDOM_segment_t declaration --- diff --git a/contrib/randomDictBuilder/main.c b/contrib/randomDictBuilder/main.c index 1f12c7a4b..36c4326b6 100644 --- a/contrib/randomDictBuilder/main.c +++ b/contrib/randomDictBuilder/main.c @@ -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; } diff --git a/contrib/randomDictBuilder/random.c b/contrib/randomDictBuilder/random.c index 34aec39ea..5276bea96 100644 --- a/contrib/randomDictBuilder/random.c +++ b/contrib/randomDictBuilder/random.c @@ -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 */ diff --git a/contrib/randomDictBuilder/random.h b/contrib/randomDictBuilder/random.h index c3146f861..352775f95 100644 --- a/contrib/randomDictBuilder/random.h +++ b/contrib/randomDictBuilder/random.h @@ -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 {