use the compiler's str.zig from platforms

This commit is contained in:
Folkert 2021-01-31 23:11:02 +01:00
parent ea05561d85
commit a79a9ea253
13 changed files with 39 additions and 15164 deletions

View file

@ -89,7 +89,10 @@ pub const RocStr = extern struct {
pub fn deinit(self: RocStr, allocator: *Allocator) void {
if (!self.isSmallStr() and !self.isEmpty()) {
const str_bytes_ptr: [*]u8 = self.str_bytes orelse unreachable;
const str_bytes: []u8 = str_bytes_ptr[0..self.str_len];
// include the refcount bytes
const refcount_bytes = @sizeOf(usize);
const str_bytes: []u8 = (str_bytes_ptr - refcount_bytes)[0 .. self.str_len + refcount_bytes];
allocator.free(str_bytes);
}
}