mirror of
https://github.com/ziglang/zig.git
synced 2026-02-18 23:39:17 +00:00
std: return Elf object from constructors instead of filling in pointer
This commit is contained in:
parent
57830e43ee
commit
521aaf3501
@ -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{
|
||||
|
||||
10
std/elf.zig
10
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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user