diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-01-16 19:49:58 +0100 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-01-16 19:49:58 +0100 |
commit | abef42f0fb968e8489b2ac46963530ab81e2f3c1 (patch) | |
tree | 0b0573b40c8e7a9adfc4b2a26e9f1ab3e9bfe70e | |
parent | eef1dd9c03642f1abeee307a6786566ce3ef7e06 (diff) | |
download | xine-lib-abef42f0fb968e8489b2ac46963530ab81e2f3c1.tar.gz xine-lib-abef42f0fb968e8489b2ac46963530ab81e2f3c1.tar.bz2 |
Make _x_canonicalise_url an inline function, as it's only ever used once (either in input_http or in the test for http_helper).
-rw-r--r-- | src/input/http_helper.c | 23 | ||||
-rw-r--r-- | src/input/http_helper.h | 24 |
2 files changed, 23 insertions, 24 deletions
diff --git a/src/input/http_helper.c b/src/input/http_helper.c index 83562c9dc..f4950a084 100644 --- a/src/input/http_helper.c +++ b/src/input/http_helper.c @@ -220,29 +220,6 @@ error: return 0; } -char *_x_canonicalise_url (const char *base, const char *url) { - - size_t base_length; - char *cut, *ret; - - if ((cut = strstr (url, "://"))) - return strdup (url); - - cut = strstr (base, "://"); - if (url[0] == '/') { - /* absolute - base up to first '/' after "://", then url */ - cut = strchr (cut + 3, '/'); - } - else { - /* relative - base up to & inc. last '/', then url */ - cut = strrchr (cut, '/'); - if (cut) - ++cut; - } - base_length = cut ? (size_t)(cut - base) : strlen (base); - asprintf (&ret, "%.*s%s", (int)base_length, base, url); - return ret; -} #ifdef TEST_URL /* diff --git a/src/input/http_helper.h b/src/input/http_helper.h index 3ce3f2b7c..9baa05235 100644 --- a/src/input/http_helper.h +++ b/src/input/http_helper.h @@ -43,6 +43,28 @@ int _x_parse_url (char *url, char **proto, char** host, int *port, * return: * the canonicalised URL (caller must free() it) */ -char *_x_canonicalise_url (const char *base, const char *url); +static inline char *_x_canonicalise_url (const char *base, const char *url) { + + size_t base_length; + char *cut, *ret; + + if ((cut = strstr (url, "://"))) + return strdup (url); + + cut = strstr (base, "://"); + if (url[0] == '/') { + /* absolute - base up to first '/' after "://", then url */ + cut = strchr (cut + 3, '/'); + } + else { + /* relative - base up to & inc. last '/', then url */ + cut = strrchr (cut, '/'); + if (cut) + ++cut; + } + base_length = cut ? (size_t)(cut - base) : strlen (base); + asprintf (&ret, "%.*s%s", (int)base_length, base, url); + return ret; +} #endif /* HTTP_HELPER_H */ |