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