Add cleanup to trainfromFiles and move RANDOM_segment_t declaration

This commit is contained in:
Jennifer Liu
2018-07-18 10:40:13 -07:00
parent ce09fb723d
commit 52e7cf0e40
3 changed files with 11 additions and 8 deletions
+2 -1
View File
@@ -114,7 +114,7 @@ int RANDOM_trainFromFiles(const char* dictFileName, sampleInfo *info,
if (ZDICT_isError(dictSize)) { if (ZDICT_isError(dictSize)) {
DISPLAYLEVEL(1, "dictionary training failed : %s \n", ZDICT_getErrorName(dictSize)); /* should not happen */ DISPLAYLEVEL(1, "dictionary training failed : %s \n", ZDICT_getErrorName(dictSize)); /* should not happen */
result = 1; result = 1;
free(dictBuffer); goto _cleanup;
} }
/* save dict */ /* save dict */
DISPLAYLEVEL(2, "Save dictionary of size %u into file %s \n", (U32)dictSize, dictFileName); 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 */ /* clean up */
_cleanup:
free(dictBuffer); free(dictBuffer);
return result; return result;
} }
+9
View 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 * Selects a random segment from totalSamplesSize - k + 1 possible segments
*/ */
-7
View File
@@ -8,13 +8,6 @@
#endif #endif
#include "zdict.h" #include "zdict.h"
/**
* A segment is an inclusive range in the source.
*/
typedef struct {
U32 begin;
U32 end;
} RANDOM_segment_t;
typedef struct { typedef struct {