memmem

public func memmem(consuming RawPointer, consuming Int64, consuming RawPointer, consuming Int64) -> RawPointer

Wraps memmem(3) — locates the first occurrence of the needleLen-byte needle in the haystackLen-byte haystack.

Returns a pointer to the start of the match, or null if not found. needleLen == 0 returns haystack (per glibc/macOS conventions — callers should check this before calling). Available on Linux and macOS; not on Windows.

Safety

haystack must be valid for haystackLen bytes; needle must be valid for needleLen bytes.

Defined in lang/std/ffi/libc.ks