Skip to content

Commit 945cd6f

Browse files
committed
fix(webui): improve compatibility and memory handling
- replace deprecated std.posix.exit with std.process.exit in build script - use std.mem.span to convert C string to Zig slice in getLastError - fix memcpy to cast src pointer as mutable for FFI compatibility
1 parent 087a51b commit 945cd6f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn build(b: *Build) !void {
4343
log.info("enable TLS support", .{});
4444
if (!target.query.isNative()) {
4545
log.info("when enable tls, not support cross compile", .{});
46-
std.posix.exit(1);
46+
std.process.exit(1);
4747
}
4848
}
4949

src/webui.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub const WebUIErrorInfo = struct {
5757
pub fn getLastError() WebUIErrorInfo {
5858
return .{
5959
.num = c.webui_get_last_error_number(),
60-
.msg = c.webui_get_last_error_message(),
60+
.msg = std.mem.span(c.webui_get_last_error_message()),
6161
};
6262
}
6363

@@ -350,7 +350,7 @@ pub fn malloc(size: usize) ![]u8 {
350350
/// Copy raw data
351351
/// In general, you should not use this function
352352
pub fn memcpy(dst: []u8, src: []const u8) void {
353-
c.webui_memcpy(@ptrCast(dst.ptr), @ptrCast(src.ptr), src.len);
353+
c.webui_memcpy(@ptrCast(dst.ptr), @ptrCast(@constCast(src.ptr)), src.len);
354354
}
355355

356356
/// Safely send raw data to the UI. All clients.

0 commit comments

Comments
 (0)