getpwuid(mingw): initialize the structure only once
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
cae598d998
commit
55b6513e73
@ -1770,16 +1770,27 @@ int mingw_getpagesize(void)
|
|||||||
|
|
||||||
struct passwd *getpwuid(int uid)
|
struct passwd *getpwuid(int uid)
|
||||||
{
|
{
|
||||||
|
static unsigned initialized;
|
||||||
static char user_name[100];
|
static char user_name[100];
|
||||||
static struct passwd p;
|
static struct passwd *p;
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
DWORD len = sizeof(user_name);
|
if (initialized)
|
||||||
if (!GetUserName(user_name, &len))
|
return p;
|
||||||
|
|
||||||
|
len = sizeof(user_name);
|
||||||
|
if (!GetUserName(user_name, &len)) {
|
||||||
|
initialized = 1;
|
||||||
return NULL;
|
return NULL;
|
||||||
p.pw_name = user_name;
|
}
|
||||||
p.pw_gecos = "unknown";
|
|
||||||
p.pw_dir = NULL;
|
p = xmalloc(sizeof(*p));
|
||||||
return &p;
|
p->pw_name = user_name;
|
||||||
|
p->pw_gecos = "unknown";
|
||||||
|
p->pw_dir = NULL;
|
||||||
|
|
||||||
|
initialized = 1;
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HANDLE timer_event;
|
static HANDLE timer_event;
|
||||||
|
Loading…
Reference in New Issue
Block a user