mirror of https://github.com/fairyglade/ly.git
				
				
				
			Fix some bugs (hopefully)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
		
							parent
							
								
									c03e2e6b87
								
							
						
					
					
						commit
						74556479db
					
				
							
								
								
									
										12
									
								
								src/main.zig
								
								
								
								
							
							
						
						
									
										12
									
								
								src/main.zig
								
								
								
								
							|  | @ -80,6 +80,9 @@ pub fn main() !void { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Initialize information line with host name |     // Initialize information line with host name | ||||||
|  |     var got_host_name = false; | ||||||
|  |     var host_name_buffer: []u8 = undefined; | ||||||
|  | 
 | ||||||
|     get_host_name: { |     get_host_name: { | ||||||
|         const host_name_struct = interop.getHostName(allocator) catch |err| { |         const host_name_struct = interop.getHostName(allocator) catch |err| { | ||||||
|             if (err == error.CannotGetHostName) { |             if (err == error.CannotGetHostName) { | ||||||
|  | @ -89,8 +92,9 @@ pub fn main() !void { | ||||||
|             } |             } | ||||||
|             break :get_host_name; |             break :get_host_name; | ||||||
|         }; |         }; | ||||||
|         defer allocator.free(host_name_struct.buffer); |  | ||||||
| 
 | 
 | ||||||
|  |         got_host_name = true; | ||||||
|  |         host_name_buffer = host_name_struct.buffer; | ||||||
|         info_line = host_name_struct.slice; |         info_line = host_name_struct.slice; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -134,14 +138,14 @@ pub fn main() !void { | ||||||
|         const reader = file.reader(); |         const reader = file.reader(); | ||||||
|         const username_length = try reader.readIntLittle(u64); |         const username_length = try reader.readIntLittle(u64); | ||||||
| 
 | 
 | ||||||
|         const username_buffer = try file.readToEndAlloc(allocator, username_length); |         const username_buffer = try reader.readAllAlloc(allocator, username_length); | ||||||
|         defer allocator.free(username_buffer); |         defer allocator.free(username_buffer); | ||||||
| 
 | 
 | ||||||
|         _ = try reader.read(username_buffer); |         _ = try reader.read(username_buffer); | ||||||
| 
 | 
 | ||||||
|         const current_desktop = try reader.readIntLittle(u64); |         const current_desktop = try reader.readIntLittle(u64); | ||||||
| 
 | 
 | ||||||
|         const load_buffer = try file.readToEndAlloc(allocator, config.ly.max_login_len + 5); |         const load_buffer = try reader.readAllAlloc(allocator, config.ly.max_login_len + 5); | ||||||
|         defer allocator.free(load_buffer); |         defer allocator.free(load_buffer); | ||||||
| 
 | 
 | ||||||
|         if (username_buffer.len > 0) { |         if (username_buffer.len > 0) { | ||||||
|  | @ -509,6 +513,8 @@ pub fn main() !void { | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (got_host_name) allocator.free(host_name_buffer); | ||||||
|  | 
 | ||||||
|     if (shutdown) { |     if (shutdown) { | ||||||
|         return std.process.execv(allocator, &[_][]const u8{ "/bin/sh", "-c", config.ly.shutdown_cmd }); |         return std.process.execv(allocator, &[_][]const u8{ "/bin/sh", "-c", config.ly.shutdown_cmd }); | ||||||
|     } else if (restart) { |     } else if (restart) { | ||||||
|  |  | ||||||
|  | @ -103,7 +103,7 @@ pub fn addEnvironmentWithBuffer(self: *Desktop, entry_buffer: []u8, name: []cons | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn crawl(self: *Desktop, path: []const u8, display_server: DisplayServer) !void { | pub fn crawl(self: *Desktop, path: []const u8, display_server: DisplayServer) !void { | ||||||
|     var directory = try std.fs.openDirAbsolute(path, .{}); |     var directory = std.fs.openDirAbsolute(path, .{}) catch return; | ||||||
|     defer directory.close(); |     defer directory.close(); | ||||||
| 
 | 
 | ||||||
|     var iterable_directory = try std.fs.openIterableDirAbsolute(path, .{}); |     var iterable_directory = try std.fs.openIterableDirAbsolute(path, .{}); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue