summaryrefslogtreecommitdiff
path: root/src/os_win/os_getenv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_win/os_getenv.c')
-rw-r--r--src/os_win/os_getenv.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/os_win/os_getenv.c b/src/os_win/os_getenv.c
index 9b297ac3a74..fe228328ee6 100644
--- a/src/os_win/os_getenv.c
+++ b/src/os_win/os_getenv.c
@@ -15,22 +15,22 @@
int
__wt_getenv(WT_SESSION_IMPL *session, const char *variable, const char **envp)
{
- WT_DECL_RET;
- DWORD size;
+ DWORD size, windows_error;
*envp = NULL;
- size = GetEnvironmentVariableA(variable, NULL, 0);
- if (size <= 1)
+ if ((size = GetEnvironmentVariableA(variable, NULL, 0)) <= 1)
return (WT_NOTFOUND);
- WT_RET(__wt_calloc(session, 1, size, envp));
+ WT_RET(__wt_malloc(session, (size_t)size, envp));
- ret = GetEnvironmentVariableA(variable, *envp, size);
/* We expect the number of bytes not including nul terminator. */
- if ((ret + 1) != size)
- WT_RET_MSG(session, __wt_getlasterror(),
- "GetEnvironmentVariableA failed: %s", variable);
+ if (GetEnvironmentVariableA(variable, *envp, size) == size - 1)
+ return (0);
- return (0);
+ windows_error = __wt_getlasterror();
+ __wt_errx(session,
+ "GetEnvironmentVariableA: %s: %s",
+ variable, __wt_formatmessage(session, windows_error));
+ return (__wt_map_windows_error(windows_error));
}