bloat-buster/tests/slice_of_slices.bbb
David Gonzalez Martin 1e6dd642d9
All checks were successful
CI / ci (ReleaseFast, ubuntu-latest) (pull_request) Successful in 2m27s
CI / ci (ReleaseSmall, ubuntu-latest) (pull_request) Successful in 2m23s
CI / ci (ReleaseSafe, ubuntu-latest) (pull_request) Successful in 2m28s
CI / ci (Debug, ubuntu-latest) (pull_request) Successful in 3m43s
CI / ci (ReleaseFast, ubuntu-latest) (push) Successful in 2m13s
CI / ci (ReleaseSmall, ubuntu-latest) (push) Successful in 2m13s
CI / ci (ReleaseSafe, ubuntu-latest) (push) Successful in 2m20s
CI / ci (Debug, ubuntu-latest) (push) Successful in 3m29s
Enum name and slice of slices
2025-04-20 13:02:43 -06:00

32 lines
651 B
Plaintext

[extern] memcmp = fn [cc(c)] (a: &u8, b: &u8, byte_count: u64) s32;
join = fn (slice: []u8, parts: [][]u8) void
{
>destination_i: u64 = 0;
for (part: parts)
{
>source_i: u64 = 0;
while (source_i < part.length)
{
slice[destination_i] = part[source_i];
destination_i += 1;
source_i += 1;
}
}
}
[export] main = fn [cc(c)] () s32
{
>a = "a";
>b = "b";
>ab = "ab";
>buffer: [2]u8 = undefined;
>buffer_slice = buffer[..];
join(buffer_slice, [ a, b ][..]);
>result = memcmp(buffer_slice.pointer, ab.pointer, ab.length);
return result;
}