From 3c43bc9208701af151a0346744e3bfc7eae43042 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 6 Jan 2016 01:28:58 -0700 Subject: support unknown size arrays --- std/std.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'std/std.zig') diff --git a/std/std.zig b/std/std.zig index 4b47100b59..ad6acea51d 100644 --- a/std/std.zig +++ b/std/std.zig @@ -39,13 +39,13 @@ pub fn os_get_random_bytes(buf: &u8, count: usize) -> isize { // TODO error handling // TODO handle buffering and flushing (mutex protected) -pub fn print_str(str: string) -> isize { +pub fn print_str(str: []const u8) -> isize { fprint_str(stdout_fileno, str) } // TODO error handling // TODO handle buffering and flushing (mutex protected) -pub fn fprint_str(fd: isize, str: string) -> isize { +pub fn fprint_str(fd: isize, str: []const u8) -> isize { write(fd, str.ptr, str.len) } @@ -73,6 +73,9 @@ fn digit_to_char(digit: u64) -> u8 { const max_u64_base10_digits: usize = 20; +// TODO use an array for out_buf instead of pointer. this should give bounds checking in +// debug mode and length can get optimized out in release mode. requires array slicing syntax +// for the buf_print_u64 call. fn buf_print_i64(out_buf: &u8, x: i64) -> usize { if (x < 0) { out_buf[0] = '-'; @@ -82,6 +85,7 @@ fn buf_print_i64(out_buf: &u8, x: i64) -> usize { } } +// TODO use an array for out_buf instead of pointer. fn buf_print_u64(out_buf: &u8, x: u64) -> usize { var buf: [max_u64_base10_digits]u8; var a = x; -- cgit v1.2.3