Add cleanup to trainfromFiles and move RANDOM_segment_t declaration
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user