MCPcopy Create free account
hub / github.com/F-Stack/f-stack / BIT_reloadDStream

Function BIT_reloadDStream

freebsd/contrib/openzfs/module/zstd/lib/zstd.c:1712–1736  ·  view source on GitHub ↗

! BIT_reloadDStream() : * Refill `bitD` from buffer previously set in BIT_initDStream() . * This function is safe, it guarantees it will not read beyond src buffer. * @return : status of `BIT_DStream_t` internal register. * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */

Source from the content-addressed store, hash-verified

1710 * @return : status of `BIT_DStream_t` internal register.
1711 * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
1712MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
1713{
1714 if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
1715 return BIT_DStream_overflow;
1716
1717 if (bitD->ptr >= bitD->limitPtr) {
1718 return BIT_reloadDStreamFast(bitD);
1719 }
1720 if (bitD->ptr == bitD->start) {
1721 if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
1722 return BIT_DStream_completed;
1723 }
1724 /* start < ptr < limitPtr */
1725 { U32 nbBytes = bitD->bitsConsumed >> 3;
1726 BIT_DStream_status result = BIT_DStream_unfinished;
1727 if (bitD->ptr - nbBytes < bitD->start) {
1728 nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */
1729 result = BIT_DStream_endOfBuffer;
1730 }
1731 bitD->ptr -= nbBytes;
1732 bitD->bitsConsumed -= nbBytes*8;
1733 bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
1734 return result;
1735 }
1736}
1737
1738/*! BIT_endOfDStream() :
1739 * @return : 1 if DStream has _exactly_ reached its end (all bits consumed).

Callers 9

zstd.cFile · 0.70
FSE_initDStateFunction · 0.70
HUF_decodeStreamX1Function · 0.70
HUF_decodeStreamX2Function · 0.70
ZSTD_initFseStateFunction · 0.70
ZSTD_decodeSequenceFunction · 0.70

Calls 2

BIT_reloadDStreamFastFunction · 0.85
MEM_readLESTFunction · 0.70

Tested by

no test coverage detected