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

Function ZSTD_isFrame

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

! ZSTD_isFrame() : * Tells if the content of `buffer` starts with a valid Frame Identifier. * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. * Note 3 : Skippable Frame Identifiers are considered valid. */

Source from the content-addressed store, hash-verified

24699 * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
24700 * Note 3 : Skippable Frame Identifiers are considered valid. */
24701unsigned ZSTD_isFrame(const void* buffer, size_t size)
24702{
24703 if (size < ZSTD_FRAMEIDSIZE) return 0;
24704 { U32 const magic = MEM_readLE32(buffer);
24705 if (magic == ZSTD_MAGICNUMBER) return 1;
24706 if ((magic & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) return 1;
24707 }
24708#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
24709 if (ZSTD_isLegacy(buffer, size)) return 1;
24710#endif
24711 return 0;
24712}
24713
24714/** ZSTD_frameHeaderSize_internal() :
24715 * srcSize must be large enough to reach header size fields.

Callers

nothing calls this directly

Calls 2

MEM_readLE32Function · 0.70
ZSTD_isLegacyFunction · 0.70

Tested by

no test coverage detected