mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
use decref to deallocate RocStr in zig code
This commit is contained in:
parent
6d941e242e
commit
870adb20a8
2 changed files with 3 additions and 6 deletions
|
@ -79,12 +79,8 @@ 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;
|
||||
|
||||
// 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);
|
||||
const alignment = @alignOf(usize);
|
||||
utils.decref(allocator, alignment, self.str_bytes, self.str_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue