strengthened conditions for using workplace into fse table space
ensure that the structure layout is as expected. will trigger an error if it changes in the future. Another solution would be to use a union, this would be cleaner and get rid of these static asserts. However, in order to keep the current code unmodified, it would be necessary to use an un-named unions. And apparently, un-named unions are only possible on "recent" compilers (C99+).
This commit is contained in:
parent
b036b9a177
commit
f97ca36eab
@ -2203,8 +2203,13 @@ static size_t ZSTD_loadEntropy(ZSTD_entropyDTables_t* entropy,
|
||||
const BYTE* const dictEnd = dictPtr + dictSize;
|
||||
|
||||
if (dictSize <= 8) return ERROR(dictionary_corrupted);
|
||||
assert(MEM_readLE32(dict) == ZSTD_MAGIC_DICTIONARY); /* dict must be valid */
|
||||
dictPtr += 8; /* skip header = magic + dictID */
|
||||
|
||||
ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, LLTable) == 0);
|
||||
ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, OFTable) == sizeof(entropy->LLTable));
|
||||
ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, MLTable) == sizeof(entropy->LLTable) + sizeof(entropy->OFTable));
|
||||
ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, hufTable) == sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable));
|
||||
ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, hufTable) >= HUF_DECOMPRESS_WORKSPACE_SIZE);
|
||||
{ void* const workspace = entropy; /* use fse tables as temporary workspace; implies fse table precede huffTable at beginning of entropy */
|
||||
size_t const workspaceSize = offsetof(ZSTD_entropyDTables_t, hufTable);
|
||||
|
Loading…
Reference in New Issue
Block a user