This commit is contained in:
Adrien Bouvais 2024-11-01 20:40:18 +01:00
parent 557e4ab064
commit bead52df5a
2 changed files with 3 additions and 3 deletions

View File

@ -200,11 +200,11 @@ pub const FileEngine = struct {
// Deinit the struct array before creating a new one
for (self.struct_array) |*elem| elem.deinit();
self.allocator(self.struct_array);
self.allocator.free(self.struct_array);
var struct_array = std.ArrayList(SchemaStruct).init(self.allocator);
parser.parse(&struct_array) catch return error.SchemaNotConform;
self.struct_array = struct_array.toOwnedSlice();
self.struct_array = struct_array.toOwnedSlice() catch return FileEngineError.MemoryError;
const path = std.fmt.allocPrint(self.allocator, "{s}/DATA", .{self.path_to_ZipponDB_dir}) catch return FileEngineError.MemoryError;
defer self.allocator.free(path);

View File

@ -174,7 +174,7 @@ pub fn main() !void {
.expect_path_to_new_db => switch (token.tag) {
.identifier => {
file_engine.deinit();
file_engine = FileEngine.init(allocator, try allocator.dupe(u8, toker.getTokenSlice(token)));
file_engine = try FileEngine.init(allocator, try allocator.dupe(u8, toker.getTokenSlice(token)));
file_engine.checkAndCreateDirectories() catch |err| {
send("Error: Coulnt create database directories: {any}", .{err});
state = .end;