MCPcopy Create free account
hub / github.com/TruthHun/BookStack / inflateSetDictionary

Function inflateSetDictionary

static/word2md/mammoth.browser.js:21952–21986  ·  view source on GitHub ↗
(strm, dictionary)

Source from the content-addressed store, hash-verified

21950}
21951
21952function inflateSetDictionary(strm, dictionary) {
21953 var dictLength = dictionary.length;
21954
21955 var state;
21956 var dictid;
21957 var ret;
21958
21959 /* check state */
21960 if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
21961 state = strm.state;
21962
21963 if (state.wrap !== 0 && state.mode !== DICT) {
21964 return Z_STREAM_ERROR;
21965 }
21966
21967 /* check for correct dictionary identifier */
21968 if (state.mode === DICT) {
21969 dictid = 1; /* adler32(0, null, 0)*/
21970 /* dictid = adler32(dictid, dictionary, dictLength); */
21971 dictid = adler32(dictid, dictionary, dictLength, 0);
21972 if (dictid !== state.check) {
21973 return Z_DATA_ERROR;
21974 }
21975 }
21976 /* copy dictionary to window using updatewindow(), which will amend the
21977 existing dictionary if appropriate */
21978 ret = updatewindow(strm, dictionary, dictLength, dictLength);
21979 if (ret) {
21980 state.mode = MEM;
21981 return Z_MEM_ERROR;
21982 }
21983 state.havedict = 1;
21984 // Tracev((stderr, "inflate: dictionary set\n"));
21985 return Z_OK;
21986}
21987
21988exports.inflateReset = inflateReset;
21989exports.inflateReset2 = inflateReset2;

Callers

nothing calls this directly

Calls 2

adler32Function · 0.70
updatewindowFunction · 0.70

Tested by

no test coverage detected