MCPcopy Create free account
hub / github.com/GNOME/gjs / zero_terminated_length

Function zero_terminated_length

gjs/text-encoding.cpp:253–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251// Finds the length of a given data array, stopping at the first 0 byte.
252template <class T>
253[[nodiscard]]
254static size_t zero_terminated_length(const T* data, size_t len) {
255 if (!data || len == 0)
256 return 0;
257
258 const T* start = data;
259 auto* found = static_cast<const T*>(memchr(start, '\0', len));
260
261 // If a null byte was not found, return the passed length.
262 if (!found)
263 return len;
264
265 return std::distance(start, found);
266}
267
268// decode() function implementation
269JSString* gjs_decode_from_uint8array(JSContext* cx, JS::HandleObject byte_array,

Callers 2

gjs_encode_to_uint8arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected