| author | |
| committer | |
| log | a8590c12cf668eb7becd862fc10cd8f77ad003a5 |
| tree | 886ca2bc46c5528400174b6ccf3848fd632a3860 |
| parent | 2e97ffbdeda9c737f12b819fbf052b629cfbd6bd |
6 files changed, 7 insertions(+), 7 deletions(-)
src/cmd/aquila/install.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ pub fn execute(args: [][]u8) !void { |
| 18 | 18 | defer f.close(); |
| 19 | 19 | const w = f.writer(); |
| 20 | 20 | const init = @import("../init.zig"); |
| 21 | try init.writeExeManifest(w, try u.random_string(48), "zigmod_installation", null, null); | |
| 21 | try init.writeExeManifest(w, try u.random_string(gpa, 48), "zigmod_installation", null, null); | |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | // add to ~/zig.mod for later |
src/cmd/init.zig+1-1| ... | ... | @@ -26,7 +26,7 @@ pub fn execute(args: [][]u8) !void { |
| 26 | 26 | const stdin = std.io.getStdIn().reader(); |
| 27 | 27 | const cwd = std.fs.cwd(); |
| 28 | 28 | |
| 29 | const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", string, "{s}", try u.random_string(48)); | |
| 29 | const id = try inquirer.answer(stdout, "ID (this gets autogenerated):", string, "{s}", try u.random_string(gpa, 48)); | |
| 30 | 30 | |
| 31 | 31 | const ptype = try inquirer.forEnum(stdout, stdin, "Are you making an application or a library?", gpa, enum { exe, lib }, null); |
| 32 | 32 |
src/common.zig+1-1| ... | ... | @@ -263,7 +263,7 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO |
| 263 | 263 | dd.dep = d.*; |
| 264 | 264 | const save = dd; |
| 265 | 265 | if (d.type != .local) dd.clean_path = u.trim_prefix(modpath, cachepath)[1..]; |
| 266 | if (dd.id.len == 0) dd.id = try u.random_string(48); | |
| 266 | if (dd.id.len == 0) dd.id = try u.random_string(gpa, 48); | |
| 267 | 267 | if (d.name.len > 0) dd.name = d.name; |
| 268 | 268 | if (d.main.len > 0) dd.main = d.main; |
| 269 | 269 | if (d.c_include_dirs.len > 0) dd.c_include_dirs = d.c_include_dirs; |
src/util/funcs.zig+2-2| ... | ... | @@ -170,11 +170,11 @@ pub fn last(in: []string) !string { |
| 170 | 170 | |
| 171 | 171 | const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"; |
| 172 | 172 | |
| 173 | pub fn random_string(len: usize) !string { | |
| 173 | pub fn random_string(alloc: *std.mem.Allocator, len: usize) !string { | |
| 174 | 174 | const now = @intCast(u64, std.time.nanoTimestamp()); |
| 175 | 175 | var rand = std.rand.DefaultPrng.init(now); |
| 176 | 176 | const r = &rand.random; |
| 177 | var buf = try gpa.alloc(u8, len); | |
| 177 | var buf = try alloc.alloc(u8, len); | |
| 178 | 178 | var i: usize = 0; |
| 179 | 179 | while (i < len) : (i += 1) { |
| 180 | 180 | buf[i] = alphabet[r.int(usize) % alphabet.len]; |
src/util/modfile.zig+1-1| ... | ... | @@ -53,7 +53,7 @@ pub const ModFile = struct { |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return Self{ |
| 56 | .id = if (id.len == 0) try u.random_string(48) else id, | |
| 56 | .id = if (id.len == 0) try u.random_string(alloc, 48) else id, | |
| 57 | 57 | .name = name, |
| 58 | 58 | .main = main, |
| 59 | 59 | .c_include_dirs = try mapping.get_string_array(alloc, "c_include_dirs"), |
src/util/module.zig+1-1| ... | ... | @@ -38,7 +38,7 @@ pub const Module = struct { |
| 38 | 38 | return Module{ |
| 39 | 39 | .alloc = alloc, |
| 40 | 40 | .is_sys_lib = false, |
| 41 | .id = if (dep.id.len > 0) dep.id else try u.random_string(48), | |
| 41 | .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48), | |
| 42 | 42 | .name = dep.name, |
| 43 | 43 | .main = dep.main, |
| 44 | 44 | .c_include_dirs = dep.c_include_dirs, |