You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had a look at getUsername and saw that it could be a little cleaner - in fact I suspect the current version has a small memory leak. My version below for what its worth.
`
func getUsername(_ uid: uid_t) -> String
{
let username: String
var passwdInfo = passwd()
var result: UnsafeMutablePointer? = nil
let bufferSize = sysconf(_SC_GETPW_R_SIZE_MAX)
var buffer = [Int8](repeating: 0, count: bufferSize)
if getpwuid_r(uid, &passwdInfo, &buffer, bufferSize, &result) == 0,
result != nil {
username = String(cString: passwdInfo.pw_name)
} else {
username = String(Int(uid))
}
return username
}`
The text was updated successfully, but these errors were encountered:
I had a look at getUsername and saw that it could be a little cleaner - in fact I suspect the current version has a small memory leak. My version below for what its worth.
`
func getUsername(_ uid: uid_t) -> String
{
let username: String
var passwdInfo = passwd()
var result: UnsafeMutablePointer? = nil
}`
The text was updated successfully, but these errors were encountered: