Skip to content

Commit

Permalink
dict-size: make lz4 context const
Browse files Browse the repository at this point in the history
change the context to const to make
clear that the context is not modified
  • Loading branch information
alexmohr committed Jun 11, 2022
1 parent 3c57d2f commit 9a42a9d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/lz4_manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ <h1>1.9.4 Manual</h1>

</p></pre><BR>

<pre><b>LZ4LIB_STATIC_API int LZ4_getDictSize (LZ4_stream_t* LZ4_dict, int dictSize);
<pre><b>LZ4LIB_STATIC_API int LZ4_getDictSize (const LZ4_stream_t* LZ4_dict, int dictSize);
</b><p> Get the size of the dictionary. This can be used for adding data without
compression to the LZ4 archive. If linked blocked mode is used the memory
of the dictionary is kept free.
Expand Down
4 changes: 2 additions & 2 deletions lib/lz4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1689,9 +1689,9 @@ int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char*
* @param dictSize The maximum dictionary size. (Normally 64 KB).
* @return The size of the dictionary.
*/
int LZ4_getDictSize (LZ4_stream_t* LZ4_dict, int dictSize)
int LZ4_getDictSize (const LZ4_stream_t* LZ4_dict, int dictSize)
{
LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse;
const LZ4_stream_t_internal* const dict = &LZ4_dict->internal_donotuse;

if ((U32)dictSize > 64 KB) { dictSize = 64 KB; } /* useless to define a dictionary > 64 KB */
if ((U32)dictSize > dict->dictSize) { dictSize = (int)dict->dictSize; }
Expand Down
2 changes: 1 addition & 1 deletion lib/lz4.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const
* @param dictSize The maximum dictionary size. (Normally 64 KB).
* @return The size of the dictionary.
*/
LZ4LIB_STATIC_API int LZ4_getDictSize (LZ4_stream_t* LZ4_dict, int dictSize);
LZ4LIB_STATIC_API int LZ4_getDictSize (const LZ4_stream_t* LZ4_dict, int dictSize);

/*! In-place compression and decompression
*
Expand Down
4 changes: 2 additions & 2 deletions lib/lz4hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,8 +1164,8 @@ int LZ4_compress_HC_continue_destSize (LZ4_streamHC_t* LZ4_streamHCPtr, const ch
* @param dictSize The maximum dictionary size. (Normally 64 KB).
* @return The size of the dictionary.
*/
int LZ4_getDictHCSize(LZ4_streamHC_t* LZ4_streamHCPtr, int dictSize) {
LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse;
int LZ4_getDictHCSize(const LZ4_streamHC_t* LZ4_streamHCPtr, int dictSize) {
const LZ4HC_CCtx_internal* const streamPtr = &LZ4_streamHCPtr->internal_donotuse;
int const prefixSize = (int)(streamPtr->end - (streamPtr->base + streamPtr->dictLimit));
DEBUGLOG(5, "LZ4_saveDictHC(%p, %p, %d)", LZ4_streamHCPtr, safeBuffer, dictSize);
assert(prefixSize >= 0);
Expand Down
2 changes: 1 addition & 1 deletion lib/lz4hc.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
* @param dictSize The maximum dictionary size. (Normally 64 KB).
* @return The size of the dictionary.
*/
LZ4LIB_STATIC_API int LZ4_getDictHCSize(LZ4_streamHC_t* LZ4_streamHCPtr, int dictSize);
LZ4LIB_STATIC_API int LZ4_getDictHCSize(const LZ4_streamHC_t* LZ4_streamHCPtr, int dictSize);

#if defined (__cplusplus)
}
Expand Down

0 comments on commit 9a42a9d

Please sign in to comment.