Commit 521aaf3501
std/debug.zig
@@ -1024,8 +1024,7 @@ pub fn openElfDebugInfo(
elf_seekable_stream: *DwarfSeekableStream,
elf_in_stream: *DwarfInStream,
) !DwarfInfo {
- var efile: elf.Elf = undefined;
- try efile.openStream(allocator, elf_seekable_stream, elf_in_stream);
+ var efile = try elf.Elf.openStream(allocator, elf_seekable_stream, elf_in_stream);
errdefer efile.close();
var di = DwarfInfo{
std/elf.zig
@@ -371,21 +371,21 @@ pub const Elf = struct {
prealloc_file: File,
/// Call close when done.
- pub fn openPath(elf: *Elf, allocator: *mem.Allocator, path: []const u8) !void {
+ pub fn openPath(allocator: *mem.Allocator, path: []const u8) !Elf {
@compileError("TODO implement");
}
/// Call close when done.
- pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: File) !void {
+ pub fn openFile(allocator: *mem.Allocator, file: File) !Elf {
@compileError("TODO implement");
}
pub fn openStream(
- elf: *Elf,
allocator: *mem.Allocator,
seekable_stream: *io.SeekableStream(anyerror, anyerror),
in: *io.InStream(anyerror),
- ) !void {
+ ) !Elf {
+ var elf: Elf = undefined;
elf.auto_close_stream = false;
elf.allocator = allocator;
elf.seekable_stream = seekable_stream;
@@ -523,6 +523,8 @@ pub const Elf = struct {
// not a string table
return error.InvalidFormat;
}
+
+ return elf;
}
pub fn close(elf: *Elf) void {