1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:57:44 +00:00

LibC: Use AK::String-backed buffers instead of static buffers

Also, refactor the hell out of pwd.cpp & grp.cpp
This commit is contained in:
Sergey Bugaev 2020-08-25 17:21:45 +03:00 committed by Andreas Kling
parent 5fd88e51c5
commit 17109a3a31
4 changed files with 192 additions and 189 deletions

View file

@ -557,14 +557,14 @@ int set_process_icon(int icon_id)
char* getlogin()
{
static char __getlogin_buffer[256];
if (auto* passwd = getpwuid(getuid())) {
strlcpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer));
static String buffer;
if (buffer.is_null()) {
if (auto* passwd = getpwuid(getuid())) {
buffer = String(passwd->pw_name);
}
endpwent();
return __getlogin_buffer;
}
endpwent();
return nullptr;
return const_cast<char*>(buffer.characters());
}
int ftruncate(int fd, off_t length)