authorgravatar for 13811862+thechampagne@users.noreply.github.comXXIV <13811862+thechampagne@users.noreply.github.com> 2023-11-04 13:17:44+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-11-06 23:46:17+02:00
log5ea973dc39cc1b3a9826ef94affb33e41c02c733
tree17899d2ec52ca8616632278ca58a6d69a3c26e33
parent9ced27dace99da1f2bc704b4d5a7fabe9a62eca4

langref: fix malloc return type


1 files changed, 2 insertions(+), 2 deletions(-)

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