Content deleted Content added
m fix doubled comma (before & after parenthesis) |
Allocators in Zig tend to be passed around by value, rather than by pointer. Additionally, the package manager can also fetch packages from git repos, using the git+https protocol, and Zig packages do not actually need to have any Zig code. |
||
Line 60:
In the code, the function would examine the size of {{code|original}} and then malloc {{code|times}} that length to set aside memory for the string it will build. That malloc is invisible to the functions calling it, if they fail to later release the memory, a leak will occur. In Zig, this might be handled using a function like:
<syntaxhighlight lang="zig">
fn repeat(allocator:
</syntaxhighlight>
Line 107:
==Packages==
Version 0.11.0 bundles an experimental [[package manager]], but no official [[software repository|package repository]] is available. Instead a package is simply a URL that points to a [[Compressed file library|compressed file]], or a [[Git]] [[Repository (version control)| repository]]. Each package ideally includes a standard `build.zig` file (that the Zig compiler uses by convention to compile the source code) and
==Examples==
Line 198:
fn repeat(
allocator:
original: []const u8,
times: usize,
Line 230:
const original = "Hello ";
const repeated = try repeat(
original,
3,
|