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
signaturelock-open 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(...@@ -1024,8 +1024,7 @@ pub fn openElfDebugInfo(
1024 elf_seekable_stream: *DwarfSeekableStream,1024 elf_seekable_stream: *DwarfSeekableStream,
1025 elf_in_stream: *DwarfInStream,1025 elf_in_stream: *DwarfInStream,
1026) !DwarfInfo {1026) !DwarfInfo {
1027 var efile: elf.Elf = undefined;1027 var efile = try elf.Elf.openStream(allocator, elf_seekable_stream, elf_in_stream);
1028 try efile.openStream(allocator, elf_seekable_stream, elf_in_stream);
1029 errdefer efile.close();1028 errdefer efile.close();
10301029
1031 var di = DwarfInfo{1030 var di = DwarfInfo{
std/elf.zig+6-4
...@@ -371,21 +371,21 @@ pub const Elf = struct {...@@ -371,21 +371,21 @@ pub const Elf = struct {
371 prealloc_file: File,371 prealloc_file: File,
372372
373 /// Call close when done.373 /// 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 {
375 @compileError("TODO implement");375 @compileError("TODO implement");
376 }376 }
377377
378 /// Call close when done.378 /// 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 {
380 @compileError("TODO implement");380 @compileError("TODO implement");
381 }381 }
382382
383 pub fn openStream(383 pub fn openStream(
384 elf: *Elf,
385 allocator: *mem.Allocator,384 allocator: *mem.Allocator,
386 seekable_stream: *io.SeekableStream(anyerror, anyerror),385 seekable_stream: *io.SeekableStream(anyerror, anyerror),
387 in: *io.InStream(anyerror),386 in: *io.InStream(anyerror),
388 ) !void {387 ) !Elf {
388 var elf: Elf = undefined;
389 elf.auto_close_stream = false;389 elf.auto_close_stream = false;
390 elf.allocator = allocator;390 elf.allocator = allocator;
391 elf.seekable_stream = seekable_stream;391 elf.seekable_stream = seekable_stream;
...@@ -523,6 +523,8 @@ pub const Elf = struct {...@@ -523,6 +523,8 @@ pub const Elf = struct {
523 // not a string table523 // not a string table
524 return error.InvalidFormat;524 return error.InvalidFormat;
525 }525 }
526
527 return elf;
526 }528 }
527529
528 pub fn close(elf: *Elf) void {530 pub fn close(elf: *Elf) void {