#convert []const u8 to [*:0]const u8

1 messages · Page 1 of 1 (latest)

lyric swan
#

As the title says

sonic cedar
#

allocator.dupeZ(u8, slice)

#

and then .ptr to get the pointer instead of a slice

tired carbon
#

be sure there isnt a way to do this without allocating more mem than necessary, like if your slice is from a string literal, change the signature to [:0]const u8 since string literals are already 0 terminated, but can coerce to non zeroed slices too