Skip to content

Commit 5ea973d

Browse files
thechampagneVexu
authored andcommitted
langref: fix malloc return type
1 parent 9ced27d commit 5ea973d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doc/langref.html.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6204-
extern fn malloc(size: usize) ?*u8;
6204+
extern fn malloc(size: usize) ?[*]u8;
62056205

62066206
fn 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>

0 commit comments

Comments
 (0)