mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const REFCOUNT_MAX_ISIZE: comptime isize = 0;
|
||||
const REFCOUNT_ONE_ISIZE: comptime isize = std.math.minInt(isize);
|
||||
pub const REFCOUNT_ONE: usize = @bitCast(usize, REFCOUNT_ONE_ISIZE);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue