diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 18:47:59 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 18:47:59 +0200 |
commit | 76a5b22625edfc46109064298682fb1ecdefb216 (patch) | |
tree | fa565f652c617923a8ca5b02d7bf3b5668e4b96b | |
parent | a7102bc328e3f062bc0123a70cbaadf65ac9a02c (diff) | |
download | xine-lib-76a5b22625edfc46109064298682fb1ecdefb216.tar.gz xine-lib-76a5b22625edfc46109064298682fb1ecdefb216.tar.bz2 |
Cleanup http_proxy environment variable handling.
Instead of duplicating twice the http_proxy environment variable
value, do so only once, avoid a strlen() call when checking if the
string is not empty, remove the http_proxy variable entirely, don't
free the duplicated string as that's what it's used.
-rw-r--r-- | src/input/input_http.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/input/input_http.c b/src/input/input_http.c index 3b091e7cb..deaaa0719 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -1079,25 +1079,21 @@ static void *init_class (xine_t *xine, void *data) { /* * honour http_proxy envvar */ - if((proxy_env = getenv("http_proxy")) && (strlen(proxy_env))) { + if((proxy_env = getenv("http_proxy")) && *proxy_env) { int proxy_port = DEFAULT_HTTP_PORT; - char *http_proxy = xine_xmalloc(strlen(proxy_env) + 1); char *p; if(!strncmp(proxy_env, "http://", 7)) proxy_env += 7; + + this->proxyhost_env = strdup(proxy_env); - sprintf(http_proxy, "%s", proxy_env); - - if((p = strrchr(&http_proxy[0], ':')) && (strlen(p) > 1)) { + if((p = strrchr(this->proxyhost_env, ':')) && (strlen(p) > 1)) { *p++ = '\0'; proxy_port = (int) strtol(p, &p, 10); } - this->proxyhost_env = strdup(http_proxy); this->proxyport_env = proxy_port; - - free(http_proxy); } else proxy_env = NULL; /* proxy_env can be "" */ |