atproto relay implementation in zig zlay.waow.tech
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix two 0.16 build errors: trimLeft rename, @cImport failure

- broadcaster.zig: std.mem.trimLeft → std.mem.trimStart (0.16 rename)
- main.zig: replace @cImport(@cInclude("malloc.h")) with @extern
declaration for malloc_trim — zig 0.16 C translator fails on
glibc's stdio2.h (__builtin_va_arg_pack)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

zzstoatzz f6edce6e 152508f4

+7 -4
+1 -1
src/broadcaster.zig
··· 943 943 inline for (fields) |entry| { 944 944 if (std.mem.indexOf(u8, content, entry[0])) |pos| { 945 945 const rest = content[pos + entry[0].len ..]; 946 - const trimmed = std.mem.trimLeft(u8, rest, " \t"); 946 + const trimmed = std.mem.trimStart(u8, rest, " \t"); 947 947 const end = std.mem.indexOfScalar(u8, trimmed, ' ') orelse 948 948 (std.mem.indexOfScalar(u8, trimmed, '\n') orelse trimmed.len); 949 949 if (std.fmt.parseInt(u64, trimmed[0..end], 10)) |val| {
+6 -3
src/main.zig
··· 37 37 const resync_mod = @import("resync.zig"); 38 38 const api = @import("api.zig"); 39 39 const build_options = @import("build_options"); 40 - const malloc_h = if (builtin.os.tag == .linux) @cImport(@cInclude("malloc.h")) else struct {}; 40 + const malloc_trim: ?*const fn (pad: usize) callconv(.c) c_int = if (builtin.os.tag == .linux) 41 + @extern(*const fn (pad: usize) callconv(.c) c_int, .{ .name = "malloc_trim" }) 42 + else 43 + null; 41 44 42 45 const log = std.log.scoped(.relay); 43 46 ··· 340 343 }; 341 344 342 345 // return freed pages to OS (glibc-specific, no-op on other platforms) 343 - if (comptime builtin.os.tag == .linux) { 344 - _ = malloc_h.malloc_trim(0); 346 + if (comptime malloc_trim) |trim| { 347 + _ = trim(0); 345 348 log.info("gc: malloc_trim complete", .{}); 346 349 } 347 350 }