mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
list single in zig
This commit is contained in:
parent
7b885f2e7c
commit
586727f74a
5 changed files with 44 additions and 21 deletions
|
@ -626,6 +626,18 @@ pub fn listRepeat(count: usize, alignment: usize, element: Opaque, element_width
|
|||
}
|
||||
}
|
||||
|
||||
pub fn listSingle(alignment: usize, element: Opaque, element_width: usize) callconv(.C) RocList {
|
||||
var output = RocList.allocate(std.heap.c_allocator, alignment, 1, element_width);
|
||||
|
||||
if (output.bytes) |target| {
|
||||
if (element) |source| {
|
||||
@memcpy(target, source, element_width);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
pub fn listAppend(list: RocList, alignment: usize, element: Opaque, element_width: usize) callconv(.C) RocList {
|
||||
const old_length = list.len();
|
||||
var output = list.reallocate(std.heap.c_allocator, alignment, old_length + 1, element_width);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue