mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-29 10:33:57 +00:00
vt: simplify ghostty_type_json to return null-terminated string
The function previously took a size_t* out-parameter for the string length. Since the JSON blob is now null-terminated, the len parameter is unnecessary. Remove it from the Zig implementation, C header, and the WASM example consumer which no longer needs to allocate and free a usize just to read the length.
This commit is contained in:
@@ -138,12 +138,11 @@
|
||||
wasmMemory = wasmInstance.exports.memory;
|
||||
|
||||
// Load the type layout JSON from the library
|
||||
const lenPtr = wasmInstance.exports.ghostty_wasm_alloc_usize();
|
||||
const jsonPtr = wasmInstance.exports.ghostty_type_json(lenPtr);
|
||||
const jsonLen = new DataView(wasmMemory.buffer).getUint32(lenPtr, true);
|
||||
wasmInstance.exports.ghostty_wasm_free_usize(lenPtr);
|
||||
const jsonBytes = new Uint8Array(wasmMemory.buffer, jsonPtr, jsonLen);
|
||||
typeLayout = JSON.parse(new TextDecoder().decode(jsonBytes));
|
||||
const jsonPtr = wasmInstance.exports.ghostty_type_json();
|
||||
const jsonStr = new TextDecoder().decode(
|
||||
new Uint8Array(wasmMemory.buffer, jsonPtr, wasmMemory.buffer.byteLength - jsonPtr)
|
||||
).split('\0')[0];
|
||||
typeLayout = JSON.parse(jsonStr);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user