Don't store allocator
This commit is contained in:
parent
10c8c9b98f
commit
bc8d525a3e
2 changed files with 18 additions and 21 deletions
|
|
@ -7,8 +7,6 @@ pub const MethodInfo = @import("Class/MethodInfo.zig");
|
|||
pub const AttributeInfo = @import("Class/AttributeInfo.zig").AttributeInfo;
|
||||
pub const ConstantPool = @import("Class/ConstantPool.zig");
|
||||
|
||||
allocator: std.mem.Allocator,
|
||||
|
||||
magic: u32,
|
||||
minor_version: u16,
|
||||
major_version: u16,
|
||||
|
|
@ -90,7 +88,6 @@ pub fn parse(input: *std.Io.Reader, allocator: std.mem.Allocator) (ParseError ||
|
|||
}
|
||||
|
||||
return .{
|
||||
.allocator = allocator,
|
||||
.magic = magic,
|
||||
.minor_version = minor_version,
|
||||
.major_version = major_version,
|
||||
|
|
@ -153,37 +150,37 @@ pub fn parseAttributes(input: *std.Io.Reader, constant_pool: ConstantPool, alloc
|
|||
return attributes;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
self.constant_pool.deinit(self.allocator);
|
||||
self.freeInterfaces();
|
||||
self.freeFields();
|
||||
self.freeMethods();
|
||||
self.freeAttributes();
|
||||
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
|
||||
self.constant_pool.deinit(allocator);
|
||||
self.freeInterfaces(allocator);
|
||||
self.freeFields(allocator);
|
||||
self.freeMethods(allocator);
|
||||
self.freeAttributes(allocator);
|
||||
}
|
||||
|
||||
fn freeInterfaces(self: *Self) void {
|
||||
self.allocator.free(self.interfaces);
|
||||
fn freeInterfaces(self: *Self, allocator: std.mem.Allocator) void {
|
||||
allocator.free(self.interfaces);
|
||||
}
|
||||
|
||||
fn freeFields(self: *Self) void {
|
||||
fn freeFields(self: *Self, allocator: std.mem.Allocator) void {
|
||||
for (self.fields) |*field_info| {
|
||||
field_info.deinit(self.allocator);
|
||||
field_info.deinit(allocator);
|
||||
}
|
||||
self.allocator.free(self.fields);
|
||||
allocator.free(self.fields);
|
||||
}
|
||||
|
||||
fn freeMethods(self: *Self) void {
|
||||
fn freeMethods(self: *Self, allocator: std.mem.Allocator) void {
|
||||
for (self.methods) |*method_info| {
|
||||
method_info.deinit(self.allocator);
|
||||
method_info.deinit(allocator);
|
||||
}
|
||||
self.allocator.free(self.methods);
|
||||
allocator.free(self.methods);
|
||||
}
|
||||
|
||||
fn freeAttributes(self: *Self) void {
|
||||
fn freeAttributes(self: *Self, allocator: std.mem.Allocator) void {
|
||||
for (self.attributes) |*attr| {
|
||||
attr.deinit(self.allocator);
|
||||
attr.deinit(allocator);
|
||||
}
|
||||
self.allocator.free(self.attributes);
|
||||
allocator.free(self.attributes);
|
||||
}
|
||||
|
||||
pub fn jsonStringify(self: *const Self, jws: *std.json.Stringify) !void {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
},
|
||||
else => return err,
|
||||
};
|
||||
defer class.deinit();
|
||||
defer class.deinit(allocator);
|
||||
|
||||
try stdout.print("{f}", .{ class });
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue