summaryrefslogtreecommitdiffstats
path: root/contrib/zstd/fse_decompress.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-15 18:37:28 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-15 18:37:28 +0100
commite3f66510f2e1eff26be9c5fe625e7d6183102875 (patch)
tree71e18e27968e741abdcb6729f423135cc0c0ccbe /contrib/zstd/fse_decompress.c
parentc417640a97de531729be6fc96654775aca4bda33 (diff)
downloadrspamd-e3f66510f2e1eff26be9c5fe625e7d6183102875.tar.gz
rspamd-e3f66510f2e1eff26be9c5fe625e7d6183102875.zip
[Minor] Update bundled zstd to version 1.3
Diffstat (limited to 'contrib/zstd/fse_decompress.c')
-rw-r--r--contrib/zstd/fse_decompress.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/contrib/zstd/fse_decompress.c b/contrib/zstd/fse_decompress.c
index 032e65771..8474a4c07 100644
--- a/contrib/zstd/fse_decompress.c
+++ b/contrib/zstd/fse_decompress.c
@@ -42,12 +42,15 @@
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
#else
-# ifdef __GNUC__
-# define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
-# define FORCE_INLINE static inline __attribute__((always_inline))
+# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# ifdef __GNUC__
+# define FORCE_INLINE static inline __attribute__((always_inline))
+# else
+# define FORCE_INLINE static inline
+# endif
# else
-# define FORCE_INLINE static inline
-# endif
+# define FORCE_INLINE static
+# endif /* __STDC_VERSION__ */
#endif
@@ -56,7 +59,6 @@
****************************************************************/
#include <stdlib.h> /* malloc, free, qsort */
#include <string.h> /* memcpy, memset */
-#include <stdio.h> /* printf (debug) */
#include "bitstream.h"
#define FSE_STATIC_LINKING_ONLY
#include "fse.h"
@@ -73,12 +75,6 @@
/* **************************************************************
-* Complex types
-****************************************************************/
-typedef U32 DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)];
-
-
-/* **************************************************************
* Templates
****************************************************************/
/*
@@ -297,28 +293,34 @@ size_t FSE_decompress_usingDTable(void* dst, size_t originalSize,
}
-size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize)
+size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog)
{
const BYTE* const istart = (const BYTE*)cSrc;
const BYTE* ip = istart;
short counting[FSE_MAX_SYMBOL_VALUE+1];
- DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */
unsigned tableLog;
unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
- if (cSrcSize<2) return ERROR(srcSize_wrong); /* too small input size */
-
/* normal FSE decoding mode */
- { size_t const NCountLength = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize);
- if (FSE_isError(NCountLength)) return NCountLength;
- if (NCountLength >= cSrcSize) return ERROR(srcSize_wrong); /* too small input size */
- ip += NCountLength;
- cSrcSize -= NCountLength;
- }
+ size_t const NCountLength = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize);
+ if (FSE_isError(NCountLength)) return NCountLength;
+ //if (NCountLength >= cSrcSize) return ERROR(srcSize_wrong); /* too small input size; supposed to be already checked in NCountLength, only remaining case : NCountLength==cSrcSize */
+ if (tableLog > maxLog) return ERROR(tableLog_tooLarge);
+ ip += NCountLength;
+ cSrcSize -= NCountLength;
- CHECK_F( FSE_buildDTable (dt, counting, maxSymbolValue, tableLog) );
+ CHECK_F( FSE_buildDTable (workSpace, counting, maxSymbolValue, tableLog) );
- return FSE_decompress_usingDTable (dst, maxDstSize, ip, cSrcSize, dt); /* always return, even if it is an error code */
+ return FSE_decompress_usingDTable (dst, dstCapacity, ip, cSrcSize, workSpace); /* always return, even if it is an error code */
+}
+
+
+typedef FSE_DTable DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)];
+
+size_t FSE_decompress(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize)
+{
+ DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */
+ return FSE_decompress_wksp(dst, dstCapacity, cSrc, cSrcSize, dt, FSE_MAX_TABLELOG);
}