aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/getenv.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:08 +0300
commit4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch)
tree506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/libs/curl/lib/getenv.c
parent2d37894b1b037cf24231090eda8589bbb44fb6fc (diff)
downloadydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/curl/lib/getenv.c')
-rw-r--r--contrib/libs/curl/lib/getenv.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/contrib/libs/curl/lib/getenv.c b/contrib/libs/curl/lib/getenv.c
index 92c53505c6..0c84959bc8 100644
--- a/contrib/libs/curl/lib/getenv.c
+++ b/contrib/libs/curl/lib/getenv.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,44 +27,44 @@
#include "memdebug.h"
-static char *GetEnv(const char *variable)
+static char *GetEnv(const char *variable)
{
#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_APP)
(void)variable;
return NULL;
-#elif defined(WIN32)
- /* This uses Windows API instead of C runtime getenv() to get the environment
- variable since some changes aren't always visible to the latter. #4774 */
- char *buf = NULL;
- char *tmp;
- DWORD bufsize;
- DWORD rc = 1;
- const DWORD max = 32768; /* max env var size from MSCRT source */
-
- for(;;) {
- tmp = realloc(buf, rc);
- if(!tmp) {
- free(buf);
- return NULL;
- }
-
- buf = tmp;
- bufsize = rc;
-
- /* It's possible for rc to be 0 if the variable was found but empty.
- Since getenv doesn't make that distinction we ignore it as well. */
- rc = GetEnvironmentVariableA(variable, buf, bufsize);
- if(!rc || rc == bufsize || rc > max) {
- free(buf);
- return NULL;
- }
-
- /* if rc < bufsize then rc is bytes written not including null */
- if(rc < bufsize)
- return buf;
-
- /* else rc is bytes needed, try again */
- }
+#elif defined(WIN32)
+ /* This uses Windows API instead of C runtime getenv() to get the environment
+ variable since some changes aren't always visible to the latter. #4774 */
+ char *buf = NULL;
+ char *tmp;
+ DWORD bufsize;
+ DWORD rc = 1;
+ const DWORD max = 32768; /* max env var size from MSCRT source */
+
+ for(;;) {
+ tmp = realloc(buf, rc);
+ if(!tmp) {
+ free(buf);
+ return NULL;
+ }
+
+ buf = tmp;
+ bufsize = rc;
+
+ /* It's possible for rc to be 0 if the variable was found but empty.
+ Since getenv doesn't make that distinction we ignore it as well. */
+ rc = GetEnvironmentVariableA(variable, buf, bufsize);
+ if(!rc || rc == bufsize || rc > max) {
+ free(buf);
+ return NULL;
+ }
+
+ /* if rc < bufsize then rc is bytes written not including null */
+ if(rc < bufsize)
+ return buf;
+
+ /* else rc is bytes needed, try again */
+ }
#else
char *env = getenv(variable);
return (env && env[0])?strdup(env):NULL;