diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2015-03-30 15:36:57 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2015-03-30 15:36:57 (GMT) |
commit | eeb8bea34c2df279307eaed922f3a89cc420316c (patch) | |
tree | 0f0cfb841eb0579d58077c5518255f2e517e2392 | |
parent | 002ec60f0feadc07a25a6f18a7b2b4ace3c1b718 (diff) | |
download | lz4-eeb8bea34c2df279307eaed922f3a89cc420316c.zip lz4-eeb8bea34c2df279307eaed922f3a89cc420316c.tar.gz lz4-eeb8bea34c2df279307eaed922f3a89cc420316c.tar.bz2 |
Updated comments on LZ4F_getFrameInfo()
-rw-r--r-- | lib/lz4frame.c | 8 | ||||
-rw-r--r-- | lib/lz4frame.h | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c index 5683eee..5f69c95 100644 --- a/lib/lz4frame.c +++ b/lib/lz4frame.c @@ -918,10 +918,10 @@ LZ4F_errorCode_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t decompressionCont if (dctxPtr->dStage == dstage_getHeader) { - LZ4F_errorCode_t errorCode = LZ4F_decodeHeader(dctxPtr, srcBuffer, *srcSizePtr); - if (LZ4F_isError(errorCode)) return errorCode; - *srcSizePtr = errorCode; /* nb Bytes consumed */ - *frameInfoPtr = dctxPtr->frameInfo; + size_t frameHeaderSize = LZ4F_decodeHeader(dctxPtr, srcBuffer, *srcSizePtr); + if (LZ4F_isError(frameHeaderSize)) return frameHeaderSize; + *srcSizePtr = frameHeaderSize; /* nb Bytes consumed */ + *frameInfoPtr = dctxPtr->frameInfo; /* copy into */ dctxPtr->srcExpect = NULL; return 4; /* nextSrcSizeHint : 4 == block header size */ } diff --git a/lib/lz4frame.h b/lib/lz4frame.h index 01a756a..9d12c7d 100644 --- a/lib/lz4frame.h +++ b/lib/lz4frame.h @@ -214,8 +214,12 @@ size_t LZ4F_getFrameInfo(LZ4F_decompressionContext_t dctx, * This function decodes frame header information, such as blockSize. * It is optional : you could start by calling directly LZ4F_decompress() instead. * The objective is to extract header information without starting decompression, typically for allocation purposes. + * The function will work only if srcBuffer points at the beginning of the frame, + * and *srcSizePtr is large enough to decode the whole header (typically, between 7 & 15 bytes). + * The result is copied into an LZ4F_frameInfo_t structure, which is pointed by frameInfoPtr, and must be already allocated. * LZ4F_getFrameInfo() can also be used *after* starting decompression, on a valid LZ4F_decompressionContext_t. * The number of bytes read from srcBuffer will be provided within *srcSizePtr (necessarily <= original value). + * It is basically the frame header size. * You are expected to resume decompression from where it stopped (srcBuffer + *srcSizePtr) * The function result is an hint of how many srcSize bytes LZ4F_decompress() expects for next call, * or an error code which can be tested using LZ4F_isError(). |