authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-08-03 15:56:25+10:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2019-08-03 15:56:25+10:00
log521aaf350185b5f01816b7a9ec604335edb3ac16
tree83019c151c5745f452f0695d6b0a1eb7ff764084
parent57830e43ee79dd0ceafc96fdad6c52e73edf1420
signature Commit is signed but in an unrecognized format.

std: return Elf object from constructors instead of filling in pointer


2 files changed, 7 insertions(+), 6 deletions(-)

std/debug.zig+1-2
......@@ -1024,8 +1024,7 @@ pub fn openElfDebugInfo(
10241024 elf_seekable_stream: *DwarfSeekableStream,
10251025 elf_in_stream: *DwarfInStream,
10261026) !DwarfInfo {
1027 var efile: elf.Elf = undefined;
1028 try efile.openStream(allocator, elf_seekable_stream, elf_in_stream);
1027 var efile = try elf.Elf.openStream(allocator, elf_seekable_stream, elf_in_stream);
10291028 errdefer efile.close();
10301029
10311030 var di = DwarfInfo{
std/elf.zig+6-4
......@@ -371,21 +371,21 @@ pub const Elf = struct {
371371 prealloc_file: File,
372372
373373 /// Call close when done.
374 pub fn openPath(elf: *Elf, allocator: *mem.Allocator, path: []const u8) !void {
374 pub fn openPath(allocator: *mem.Allocator, path: []const u8) !Elf {
375375 @compileError("TODO implement");
376376 }
377377
378378 /// Call close when done.
379 pub fn openFile(elf: *Elf, allocator: *mem.Allocator, file: File) !void {
379 pub fn openFile(allocator: *mem.Allocator, file: File) !Elf {
380380 @compileError("TODO implement");
381381 }
382382
383383 pub fn openStream(
384 elf: *Elf,
385384 allocator: *mem.Allocator,
386385 seekable_stream: *io.SeekableStream(anyerror, anyerror),
387386 in: *io.InStream(anyerror),
388 ) !void {
387 ) !Elf {
388 var elf: Elf = undefined;
389389 elf.auto_close_stream = false;
390390 elf.allocator = allocator;
391391 elf.seekable_stream = seekable_stream;
......@@ -523,6 +523,8 @@ pub const Elf = struct {
523523 // not a string table
524524 return error.InvalidFormat;
525525 }
526
527 return elf;
526528 }
527529
528530 pub fn close(elf: *Elf) void {