zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 5ea973dc39cc1b3a9826ef94affb33e41c02c733 (tree)
parent 9ced27dace99da1f2bc704b4d5a7fabe9a62eca4
Author: XXIV <13811862+thechampagne@users.noreply.github.com>
Date:   Sat,  4 Nov 2023 13:17:44 +0300

langref: fix malloc return type
Diffstat:
Mdoc/langref.html.in | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -6201,7 +6201,7 @@ struct Foo *do_a_thing(void) { <p>Zig code</p> {#syntax_block|zig|call_malloc_from_zig.zig#} // malloc prototype included for reference -extern fn malloc(size: usize) ?*u8; +extern fn malloc(size: usize) ?[*]u8; fn doAThing() ?*Foo { const ptr = malloc(1234) orelse return null; @@ -6210,7 +6210,7 @@ fn doAThing() ?*Foo { {#end_syntax_block#} <p> Here, Zig is at least as convenient, if not more, than C. And, the type of "ptr" - is {#syntax#}*u8{#endsyntax#} <em>not</em> {#syntax#}?*u8{#endsyntax#}. The {#syntax#}orelse{#endsyntax#} keyword + is {#syntax#}[*]u8{#endsyntax#} <em>not</em> {#syntax#}?[*]u8{#endsyntax#}. The {#syntax#}orelse{#endsyntax#} keyword unwrapped the optional type and therefore {#syntax#}ptr{#endsyntax#} is guaranteed to be non-null everywhere it is used in the function. </p>