From 3f5d8d1a2e844c8833eeb046fd7a84b72a3d3a1f Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 22 Jan 2017 16:11:24 +0000 Subject: nsurl: Tidy up shared components code. --- utils/nsurl/private.h | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'utils/nsurl/private.h') diff --git a/utils/nsurl/private.h b/utils/nsurl/private.h index 67945e2e7..e78f83042 100644 --- a/utils/nsurl/private.h +++ b/utils/nsurl/private.h @@ -128,7 +128,7 @@ enum nsurl_string_flags { * \param[out] url_l_out Returns byte length of string, excluding pre_padding. * \return NSERROR_OK on success, appropriate error otherwise. */ -nserror nsurl__string( +nserror nsurl__components_to_string( const struct nsurl_components *components, nsurl_component parts, size_t pre_padding, char **url_s_out, size_t *url_l_out); @@ -142,6 +142,41 @@ void nsurl__calc_hash(nsurl *url); + +/** + * Destroy components + * + * \param c url components + */ +static inline void nsurl__components_destroy(struct nsurl_components *c) +{ + if (c->scheme) + lwc_string_unref(c->scheme); + + if (c->username) + lwc_string_unref(c->username); + + if (c->password) + lwc_string_unref(c->password); + + if (c->host) + lwc_string_unref(c->host); + + if (c->port) + lwc_string_unref(c->port); + + if (c->path) + lwc_string_unref(c->path); + + if (c->query) + lwc_string_unref(c->query); + + if (c->fragment) + lwc_string_unref(c->fragment); +} + + + #ifdef NSURL_DEBUG /** * Dump a NetSurf URL's internal components -- cgit v1.2.3