Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
getpwuid(mingw): initialize the structure only once
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Mon, 15 Oct 2018 09:47:05 +0000
(
02:47
-0700)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 16 Oct 2018 03:59:57 +0000
(12:59 +0900)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
cae598d
)
diff --git
a/compat/mingw.c
b/compat/mingw.c
index 858ca14a57351062d2bba147c72ed460fb0aa533..32fa6e7c1fa1ef06426943a66aa417f45f891c08 100644
(file)
--- a/
compat/mingw.c
+++ b/
compat/mingw.c
@@
-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 (!GetUserName(user_name, &len))
+ if (initialized)
+ 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;
- return &p;
+ }
+
+ p = xmalloc(sizeof(*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;