MCPcopy Index your code
hub / github.com/Bloom-Engine/engine / str_from_header

Function str_from_header

native/shared/src/string_header.rs:25–35  ·  view source on GitHub ↗

Extract a &str from a *const StringHeader pointer (Perry string format).

(ptr: *const u8)

Source from the content-addressed store, hash-verified

23
24/// Extract a &str from a *const StringHeader pointer (Perry string format).
25pub fn str_from_header(ptr: *const u8) -> &'static str {
26 if ptr.is_null() || (ptr as usize) < 0x1000 {
27 return "";
28 }
29 unsafe {
30 let header = ptr as *const StringHeader;
31 let len = (*header).byte_len as usize;
32 let data = ptr.add(std::mem::size_of::<StringHeader>());
33 std::str::from_utf8_unchecked(std::slice::from_raw_parts(data, len))
34 }
35}
36
37/// Allocate a Perry 0.5.x heap string suitable for returning across the
38/// FFI boundary (declared as `returns: "string"` in package.json). Layout

Callers 15

bloom_init_windowFunction · 0.85
bloom_draw_textFunction · 0.85
bloom_measure_textFunction · 0.85
bloom_load_fontFunction · 0.85
bloom_draw_text_exFunction · 0.85
bloom_measure_text_exFunction · 0.85
bloom_load_soundFunction · 0.85
bloom_load_textureFunction · 0.85
bloom_load_imageFunction · 0.85
bloom_load_modelFunction · 0.85
bloom_load_shaderFunction · 0.85
bloom_compile_materialFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected