mirror of
https://github.com/facebook/zstd.git
synced 2025-12-07 00:02:39 -05:00
free memory in test case
This commit is contained in:
parent
6ad71a3f0b
commit
aece0f258a
@ -189,18 +189,18 @@ int main(int argc, const char** argv)
|
|||||||
|
|
||||||
printf("Test %u - check ZSTD magic in compressing empty string: ", testNb++);
|
printf("Test %u - check ZSTD magic in compressing empty string: ", testNb++);
|
||||||
{ // compressing empty string should return a zstd header
|
{ // compressing empty string should return a zstd header
|
||||||
char *data_in = (char *) malloc(255 * sizeof(char));
|
size_t const capacity = 255;
|
||||||
assert(data_in != NULL);
|
char* inBuffer = malloc(capacity);
|
||||||
data_in = "\0";
|
assert(inBuffer != NULL);
|
||||||
|
inBuffer[0] = '\0';
|
||||||
char *data_out = (char *) malloc(255 * 255 * sizeof(char));
|
void* const outBuffer = malloc(capacity);
|
||||||
assert(data_out != NULL);
|
assert(outBuffer != NULL);
|
||||||
|
|
||||||
ZSTD_seekable_CStream *s = ZSTD_seekable_createCStream();
|
ZSTD_seekable_CStream *s = ZSTD_seekable_createCStream();
|
||||||
ZSTD_seekable_initCStream(s, 1, 1, 1024 * 1024);
|
ZSTD_seekable_initCStream(s, 1, 1, 255);
|
||||||
|
|
||||||
ZSTD_inBuffer input = { data_in, 0, 0 };
|
ZSTD_inBuffer input = { .src=inBuffer, .pos=0, .size=0 };
|
||||||
ZSTD_outBuffer output = { data_out, 255*255, 0 };
|
ZSTD_outBuffer output = { .dst=outBuffer, .pos=0, .size=capacity };
|
||||||
|
|
||||||
ZSTD_seekable_compressStream(s, &output, &input);
|
ZSTD_seekable_compressStream(s, &output, &input);
|
||||||
ZSTD_seekable_endStream(s, &output);
|
ZSTD_seekable_endStream(s, &output);
|
||||||
@ -208,10 +208,14 @@ int main(int argc, const char** argv)
|
|||||||
if((((char*)output.dst)[0] != '\x28') | (((char*)output.dst)[1] != '\xb5') | (((char*)output.dst)[2] != '\x2f') | (((char*)output.dst)[3] != '\xfd')) {
|
if((((char*)output.dst)[0] != '\x28') | (((char*)output.dst)[1] != '\xb5') | (((char*)output.dst)[2] != '\x2f') | (((char*)output.dst)[3] != '\xfd')) {
|
||||||
printf("%#02x %#02x %#02x %#02x\n", ((char*)output.dst)[0], ((char*)output.dst)[1] , ((char*)output.dst)[2] , ((char*)output.dst)[3] );
|
printf("%#02x %#02x %#02x %#02x\n", ((char*)output.dst)[0], ((char*)output.dst)[1] , ((char*)output.dst)[2] , ((char*)output.dst)[3] );
|
||||||
|
|
||||||
|
free(inBuffer);
|
||||||
|
free(outBuffer);
|
||||||
ZSTD_seekable_freeCStream(s);
|
ZSTD_seekable_freeCStream(s);
|
||||||
goto _test_error;
|
goto _test_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(inBuffer);
|
||||||
|
free(outBuffer);
|
||||||
ZSTD_seekable_freeCStream(s);
|
ZSTD_seekable_freeCStream(s);
|
||||||
}
|
}
|
||||||
printf("Success!\n");
|
printf("Success!\n");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user