| ... | ... | @@ -35,10 +35,9 @@ pub fn init(pool: *Pool, options: Options) !void { |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | const thread_count = options.n_jobs orelse @max(1, std.Thread.getCpuCount() catch 1); |
| 38 | | pool.threads = try allocator.alloc(std.Thread, thread_count); |
| 39 | | errdefer allocator.free(pool.threads); |
| 40 | 38 | |
| 41 | | // kill and join any threads we spawned previously on error. |
| 39 | // kill and join any threads we spawned and free memory on error. |
| 40 | pool.threads = try allocator.alloc(std.Thread, thread_count); |
| 42 | 41 | var spawned: usize = 0; |
| 43 | 42 | errdefer pool.join(spawned); |
| 44 | 43 | |