mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
fix lua oom errors
This commit is contained in:
parent
9553e3831f
commit
1e973eff94
4 changed files with 14 additions and 23 deletions
|
|
@ -4,6 +4,7 @@ const std = @import("std");
|
|||
const zlua = @import("zlua");
|
||||
|
||||
const Lua = @import("Lua.zig");
|
||||
const Utils = @import("../Utils.zig");
|
||||
|
||||
const gpa = std.heap.c_allocator;
|
||||
|
||||
|
|
@ -17,9 +18,7 @@ pub fn joinpath(L: *zlua.Lua) i32 {
|
|||
return 0;
|
||||
}
|
||||
|
||||
var paths = std.ArrayList([:0]const u8).initCapacity(gpa, @intCast(nargs)) catch {
|
||||
return 0;
|
||||
};
|
||||
var paths = std.ArrayList([:0]const u8).initCapacity(gpa, @intCast(nargs)) catch Utils.oomPanic();
|
||||
defer paths.deinit(gpa);
|
||||
|
||||
var i: u8 = 1;
|
||||
|
|
@ -30,17 +29,12 @@ pub fn joinpath(L: *zlua.Lua) i32 {
|
|||
}
|
||||
|
||||
const partial_path = L.toString(i) catch unreachable;
|
||||
paths.append(gpa, partial_path) catch {
|
||||
// TODO: tell lua?
|
||||
return 0;
|
||||
};
|
||||
paths.append(gpa, partial_path) catch Utils.oomPanic();
|
||||
}
|
||||
|
||||
const final_path: []const u8 = std.fs.path.join(gpa, paths.items) catch {
|
||||
// TODO: tell lua?
|
||||
return 0;
|
||||
};
|
||||
_ = L.pushString(final_path);
|
||||
const final_path: []const u8 = std.fs.path.join(gpa, paths.items) catch Utils.oomPanic();
|
||||
defer gpa.free(final_path);
|
||||
|
||||
_ = L.pushString(final_path);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue