summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/blockStreaming_doubleBuffer.c4
-rw-r--r--examples/blockStreaming_lineByLine.c7
2 files changed, 6 insertions, 5 deletions
diff --git a/examples/blockStreaming_doubleBuffer.c b/examples/blockStreaming_doubleBuffer.c
index 094f80d..58f2bdb 100644
--- a/examples/blockStreaming_doubleBuffer.c
+++ b/examples/blockStreaming_doubleBuffer.c
@@ -53,8 +53,8 @@ void test_compress(FILE* outFp, FILE* inpFp)
{
char cmpBuf[LZ4_COMPRESSBOUND(BLOCK_BYTES)];
- const int cmpBytes = LZ4_compress_continue(
- lz4Stream, inpPtr, cmpBuf, inpBytes);
+ const int cmpBytes = LZ4_compress_safe_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, sizeof(cmpBuf));
if(cmpBytes <= 0) {
break;
}
diff --git a/examples/blockStreaming_lineByLine.c b/examples/blockStreaming_lineByLine.c
index f0f7d46..8ae268f 100644
--- a/examples/blockStreaming_lineByLine.c
+++ b/examples/blockStreaming_lineByLine.c
@@ -41,7 +41,8 @@ static void test_compress(
size_t ringBufferBytes)
{
LZ4_stream_t* const lz4Stream = LZ4_createStream();
- char* const cmpBuf = malloc(LZ4_COMPRESSBOUND(messageMaxBytes));
+ const size_t cmpBufBytes = LZ4_COMPRESSBOUND(messageMaxBytes);
+ char* const cmpBuf = malloc(cmpBufBytes);
char* const inpBuf = malloc(ringBufferBytes);
int inpOffset = 0;
@@ -63,8 +64,8 @@ static void test_compress(
#endif
{
- const int cmpBytes = LZ4_compress_continue(
- lz4Stream, inpPtr, cmpBuf, inpBytes);
+ const int cmpBytes = LZ4_compress_safe_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, cmpBufBytes);
if (cmpBytes <= 0) break;
write_uint16(outFp, (uint16_t) cmpBytes);
write_bin(outFp, cmpBuf, cmpBytes);