authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-29 19:41:16-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-05-29 19:41:16-04:00
log345501a72d9780e66beecd549cf6e56c9cde1a95
tree7f47cd4f56c5dc245bb1901c12ce7c6c6a7ce2bd
parentc66a747045e660a7e8b8146f9ee28c89f3960940
parentf2b64fd18f73fe26934b388c1da95e1b4e770c83
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2567 from emekoi/fix-dynlib

remove allocator from DynLib

1 files changed, 3 insertions(+), 5 deletions(-)

std/dynamic_library.zig+3-5
...@@ -104,7 +104,7 @@ pub const LinuxDynLib = struct {...@@ -104,7 +104,7 @@ pub const LinuxDynLib = struct {
104 memory: []align(mem.page_size) u8,104 memory: []align(mem.page_size) u8,
105105
106 /// Trusts the file106 /// Trusts the file
107 pub fn open(allocator: *mem.Allocator, path: []const u8) !DynLib {107 pub fn open(path: []const u8) !DynLib {
108 const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);108 const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);
109 errdefer os.close(fd);109 errdefer os.close(fd);
110110
...@@ -244,14 +244,12 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [...@@ -244,14 +244,12 @@ fn checkver(def_arg: *elf.Verdef, vsym_arg: i32, vername: []const u8, strings: [
244}244}
245245
246pub const WindowsDynLib = struct {246pub const WindowsDynLib = struct {
247 allocator: *mem.Allocator,
248 dll: windows.HMODULE,247 dll: windows.HMODULE,
249248
250 pub fn open(allocator: *mem.Allocator, path: []const u8) !WindowsDynLib {249 pub fn open(path: []const u8) !WindowsDynLib {
251 const wpath = try windows.sliceToPrefixedFileW(path);250 const wpath = try windows.sliceToPrefixedFileW(path);
252251
253 return WindowsDynLib{252 return WindowsDynLib{
254 .allocator = allocator,
255 .dll = try windows.LoadLibraryW(&wpath),253 .dll = try windows.LoadLibraryW(&wpath),
256 };254 };
257 }255 }
...@@ -273,7 +271,7 @@ test "dynamic_library" {...@@ -273,7 +271,7 @@ test "dynamic_library" {
273 else => return,271 else => return,
274 };272 };
275273
276 const dynlib = DynLib.open(std.debug.global_allocator, libname) catch |err| {274 const dynlib = DynLib.open(libname) catch |err| {
277 testing.expect(err == error.FileNotFound);275 testing.expect(err == error.FileNotFound);
278 return;276 return;
279 };277 };