From 5f15078644c6150dcec4be61d4c26876c8b2b530 Mon Sep 17 00:00:00 2001 From: Toni Date: Thu, 4 Jun 2026 11:09:07 +0200 Subject: [PATCH] a --- src/std/std.zr | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/std/std.zr b/src/std/std.zr index 80a5fef..ad1eba2 100644 --- a/src/std/std.zr +++ b/src/std/std.zr @@ -239,6 +239,20 @@ func mem.write16be[x: ptr, d: i64] : void func mem.write64[x: ptr, d: any] : void _builtin_set64(x, d) +struct Blob + data: ptr + size: i64 + +func Blob.alloc[size: i64] : Blob + buffer := new* Blob + buffer->size = size + buffer->data = mem.alloc(size) + return buffer + +func Blob.free[buf: Blob] : void + mem.free(buf->data) + mem.free(buf) + func io.printf[..] : void s := _var_arg(0) as ptr i := 1 @@ -319,25 +333,11 @@ func io.read_line[] : str str.Builder.free(b) return s -struct Blob - data: ptr - size: i64 - -func Blob.alloc[size: i64] : Blob - buffer := new* Blob - buffer->size = size - buffer->data = mem.alloc(size) - return buffer - -func Blob.free[buf: Blob] : void - mem.free(buf->data) - mem.free(buf) - func io.file_exists[path: str] : bool return _builtin_syscall(SYS_faccessat, -100, path, 0, 0) == 0 func io.is_a_directory[path: str] : bool - st := _stackalloc(256) // it has 21 mixed-size fields so no struct for now + st := _stackalloc(256) // it has 21 mixed-size fields so ptr for now rc := _builtin_syscall(SYS_newfstatat, -100, path, st, 0) if rc != 0 @@ -419,7 +419,7 @@ func str.equal[a: str, b: str] : bool return a[i] == b[i] func str.is_whitespace[x: u8] : bool - return x == ' ' || x == 10 || x == 13 || x == 9 + return x == ' ' || x == '\n' || x == '\t' || x == '\r' func str.is_digit[x: u8] : bool return x >= '0' && x <= '9'