summaryrefslogtreecommitdiffstats
path: root/osdep/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/io.c')
-rw-r--r--osdep/io.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/osdep/io.c b/osdep/io.c
index 21abe0e1d5..1e8171de59 100644
--- a/osdep/io.c
+++ b/osdep/io.c
@@ -27,11 +27,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
-#include <unistd.h>
#include "mpv_talloc.h"
#include "config.h"
+#include "common/common.h"
#include "misc/random.h"
#include "osdep/io.h"
#include "osdep/terminal.h"
@@ -62,7 +62,7 @@ bool mp_set_cloexec(int fd)
return true;
}
-#ifdef __MINGW32__
+#ifdef _WIN32
int mp_make_cloexec_pipe(int pipes[2])
{
pipes[0] = pipes[1] = -1;
@@ -82,7 +82,7 @@ int mp_make_cloexec_pipe(int pipes[2])
}
#endif
-#ifdef __MINGW32__
+#ifdef _WIN32
int mp_make_wakeup_pipe(int pipes[2])
{
return mp_make_cloexec_pipe(pipes);
@@ -104,7 +104,7 @@ int mp_make_wakeup_pipe(int pipes[2])
void mp_flush_wakeup_pipe(int pipe_end)
{
-#ifndef __MINGW32__
+#ifndef _WIN32
char buf[100];
(void)read(pipe_end, buf, sizeof(buf));
#endif
@@ -142,7 +142,7 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s)
#endif // _WIN32
-#ifdef __MINGW32__
+#ifdef _WIN32
#include <io.h>
#include <fcntl.h>
@@ -664,11 +664,12 @@ static void free_env(void)
static void init_getenv(void)
{
#if !HAVE_UWP
- wchar_t *wenv = GetEnvironmentStringsW();
- if (!wenv)
+ wchar_t *wenv_begin = GetEnvironmentStringsW();
+ if (!wenv_begin)
return;
utf8_environ_ctx = talloc_new(NULL);
int num_env = 0;
+ wchar_t *wenv = wenv_begin;
while (1) {
size_t len = wcslen(wenv);
if (!len)
@@ -677,6 +678,7 @@ static void init_getenv(void)
MP_TARRAY_APPEND(utf8_environ_ctx, utf8_environ, num_env, s);
wenv += len + 1;
}
+ FreeEnvironmentStringsW(wenv_begin);
MP_TARRAY_APPEND(utf8_environ_ctx, utf8_environ, num_env, NULL);
// Avoid showing up in leak detectors etc.
atexit(free_env);