X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fwindows%2Fgetopt.c;h=a1f51c6c2318e847f99cc7d5eb0a633c47356c62;hb=ba5b133e3348dd7c266791cbb456519a27b7c08c;hp=a08f7c109b5ad972d6a97a010051092f41ff103e;hpb=d87f964ce6decd07f64091a36a55642b8960fd4e;p=dpdk.git diff --git a/lib/librte_eal/windows/getopt.c b/lib/librte_eal/windows/getopt.c index a08f7c109b..a1f51c6c23 100644 --- a/lib/librte_eal/windows/getopt.c +++ b/lib/librte_eal/windows/getopt.c @@ -242,7 +242,6 @@ getopt_internal(int nargc, char **nargv, const char *options, char *oli; /* option letter list index */ int optchar, short_too; static int posixly_correct = -1; - char *buf; size_t len; int optreset = 0; @@ -253,16 +252,16 @@ getopt_internal(int nargc, char **nargv, const char *options, * Disable GNU extensions if POSIXLY_CORRECT is set or options * string begins with a '+'. */ - if (posixly_correct == -1) - posixly_correct = _dupenv_s(&buf, &len, "POSIXLY_CORRECT"); + if (posixly_correct == -1) { + errno_t err = _wgetenv_s(&len, NULL, 0, L"POSIXLY_CORRECT"); + posixly_correct = (err == 0) && (len > 0); + } if (!posixly_correct || *options == '+') flags &= ~FLAG_PERMUTE; else if (*options == '-') flags |= FLAG_ALLARGS; if (*options == '+' || *options == '-') options++; - if (!posixly_correct) - free(buf); /* * reset if requested */