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) {...@@ -6201,7 +6201,7 @@ struct Foo *do_a_thing(void) {
6201 <p>Zig code</p>6201 <p>Zig code</p>
6202 {#syntax_block|zig|call_malloc_from_zig.zig#}6202 {#syntax_block|zig|call_malloc_from_zig.zig#}
6203// malloc prototype included for reference6203// malloc prototype included for reference
6204extern fn malloc(size: usize) ?*u8;6204extern fn malloc(size: usize) ?[*]u8;
62056205
6206fn doAThing() ?*Foo {6206fn doAThing() ?*Foo {
6207 const ptr = malloc(1234) orelse return null;6207 const ptr = malloc(1234) orelse return null;
...@@ -6210,7 +6210,7 @@ fn doAThing() ?*Foo {...@@ -6210,7 +6210,7 @@ fn doAThing() ?*Foo {
6210 {#end_syntax_block#}6210 {#end_syntax_block#}
6211 <p>6211 <p>
6212 Here, Zig is at least as convenient, if not more, than C. And, the type of "ptr"6212 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#} keyword6213 is {#syntax#}[*]u8{#endsyntax#} <em>not</em> {#syntax#}?[*]u8{#endsyntax#}. The {#syntax#}orelse{#endsyntax#} keyword
6214 unwrapped the optional type and therefore {#syntax#}ptr{#endsyntax#} is guaranteed to be non-null everywhere6214 unwrapped the optional type and therefore {#syntax#}ptr{#endsyntax#} is guaranteed to be non-null everywhere
6215 it is used in the function.6215 it is used in the function.
6216 </p>6216 </p>