SOLVED THREAD BUG
Needed a thread safe alloc. Will need to update other part as I just did parseEntities and deleteEntities
This commit is contained in:
@@ -39,6 +39,10 @@ pub fn get(self: UUIDIndexMap, uuid: UUID) ?usize {
|
||||
return self.map.get(uuid);
|
||||
}
|
||||
|
||||
pub fn reset(self: *UUIDIndexMap) void {
|
||||
_ = self.arena.reset(.free_all);
|
||||
}
|
||||
|
||||
test "Create empty UUIDIndexMap" {
|
||||
const allocator = std.testing.allocator;
|
||||
|
||||
|
||||
@@ -31,6 +31,18 @@ pub fn addMember(self: *AdditionalData, name: []const u8, index: usize) ZipponEr
|
||||
self.childrens.append(AdditionalDataMember.init(self.allocator, name, index)) catch return ZipponError.MemoryError;
|
||||
}
|
||||
|
||||
pub fn clone(self: AdditionalData, allocator: Allocator) ZipponError!AdditionalData {
|
||||
var new_additional_data = AdditionalData.init(allocator);
|
||||
|
||||
new_additional_data.limit = self.limit;
|
||||
|
||||
for (self.childrens.items) |child| {
|
||||
new_additional_data.childrens.append(child.clone(allocator) catch return ZipponError.MemoryError) catch return ZipponError.MemoryError;
|
||||
}
|
||||
|
||||
return new_additional_data;
|
||||
}
|
||||
|
||||
// This is name in: [name]
|
||||
// There is an additional data because it can be [friend [1; name]]
|
||||
pub const AdditionalDataMember = struct {
|
||||
@@ -41,4 +53,12 @@ pub const AdditionalDataMember = struct {
|
||||
pub fn init(allocator: Allocator, name: []const u8, index: usize) AdditionalDataMember {
|
||||
return AdditionalDataMember{ .name = name, .index = index, .additional_data = AdditionalData.init(allocator) };
|
||||
}
|
||||
|
||||
pub fn clone(self: AdditionalDataMember, allocator: Allocator) ZipponError!AdditionalDataMember {
|
||||
return AdditionalDataMember{
|
||||
.name = allocator.dupe(u8, self.name) catch return ZipponError.MemoryError,
|
||||
.index = self.index,
|
||||
.additional_data = self.additional_data.clone(allocator) catch return ZipponError.MemoryError,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user