Mercurial > pidgin.yaz
comparison src/util.c @ 14035:8bda65b88e49
[gaim-migrate @ 16638]
A bunch of small changes. Mostly remove "if not null" checks before
calling g_free, g_list_free, g_slist_free and g_strdup. Also use
g_list_foreach() to call g_free to free strings in an array. And
some whitespace changes here and there.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 05 Aug 2006 08:27:39 +0000 |
parents | fe1c92e1494a |
children | 5e6d4c36630a |
comparison
equal
deleted
inserted
replaced
14034:0839a7b71325 | 14035:8bda65b88e49 |
---|---|
924 { | 924 { |
925 size_t len = close - cur; | 925 size_t len = close - cur; |
926 | 926 |
927 /* don't store a blank attribute name */ | 927 /* don't store a blank attribute name */ |
928 if (len) { | 928 if (len) { |
929 if (name) | 929 g_free(name); |
930 g_free(name); | |
931 name = g_ascii_strdown(cur, len); | 930 name = g_ascii_strdown(cur, len); |
932 } | 931 } |
933 | 932 |
934 in_attr = FALSE; | 933 in_attr = FALSE; |
935 cur = close + 1; | 934 cur = close + 1; |
992 } | 991 } |
993 } | 992 } |
994 } | 993 } |
995 | 994 |
996 /* clean up any attribute name from a premature termination */ | 995 /* clean up any attribute name from a premature termination */ |
997 if (name) | 996 g_free(name); |
998 g_free(name); | |
999 | 997 |
1000 if (found) { | 998 if (found) { |
1001 *attributes = attribs; | 999 *attributes = attribs; |
1002 } else { | 1000 } else { |
1003 *start = NULL; | 1001 *start = NULL; |
1768 | 1766 |
1769 char * | 1767 char * |
1770 gaim_markup_linkify(const char *text) | 1768 gaim_markup_linkify(const char *text) |
1771 { | 1769 { |
1772 const char *c, *t, *q = NULL; | 1770 const char *c, *t, *q = NULL; |
1773 char *tmp, *tmpurlbuf, *url_buf; | 1771 char *tmpurlbuf, *url_buf; |
1774 gunichar g; | 1772 gunichar g; |
1775 gboolean inside_html = FALSE; | 1773 gboolean inside_html = FALSE; |
1776 int inside_paren = 0; | 1774 int inside_paren = 0; |
1777 GString *ret = g_string_new(""); | 1775 GString *ret = g_string_new(""); |
1778 /* Assumes you have a buffer able to carry at least BUF_LEN * 2 bytes */ | 1776 /* Assumes you have a buffer able to carry at least BUF_LEN * 2 bytes */ |
2021 | 2019 |
2022 ret = g_string_append_c(ret, *c); | 2020 ret = g_string_append_c(ret, *c); |
2023 c++; | 2021 c++; |
2024 | 2022 |
2025 } | 2023 } |
2026 tmp = ret->str; | 2024 return g_string_free(ret, FALSE); |
2027 g_string_free(ret, FALSE); | |
2028 return tmp; | |
2029 } | 2025 } |
2030 | 2026 |
2031 char * | 2027 char * |
2032 gaim_unescape_html(const char *html) { | 2028 gaim_unescape_html(const char *html) { |
2033 char *unescaped = NULL; | 2029 char *unescaped = NULL; |
2108 } else if (!g_ascii_strncasecmp(str, "</", 2)) { | 2104 } else if (!g_ascii_strncasecmp(str, "</", 2)) { |
2109 /* pop stack */ | 2105 /* pop stack */ |
2110 char *tmp; | 2106 char *tmp; |
2111 | 2107 |
2112 tmp = g_queue_pop_head(q); | 2108 tmp = g_queue_pop_head(q); |
2113 if (tmp) | 2109 g_free(tmp); |
2114 g_free(tmp); | |
2115 /* z += 0; */ | 2110 /* z += 0; */ |
2116 } else { | 2111 } else { |
2117 /* push it unto the stack */ | 2112 /* push it unto the stack */ |
2118 char *tmp; | 2113 char *tmp; |
2119 | 2114 |
3428 gfud = g_new0(GaimFetchUrlData, 1); | 3423 gfud = g_new0(GaimFetchUrlData, 1); |
3429 | 3424 |
3430 gfud->callback = cb; | 3425 gfud->callback = cb; |
3431 gfud->user_data = user_data; | 3426 gfud->user_data = user_data; |
3432 gfud->url = g_strdup(url); | 3427 gfud->url = g_strdup(url); |
3433 gfud->user_agent = user_agent ? g_strdup(user_agent) : NULL; | 3428 gfud->user_agent = g_strdup(user_agent); |
3434 gfud->http11 = http11; | 3429 gfud->http11 = http11; |
3435 gfud->full = full; | 3430 gfud->full = full; |
3436 gfud->request = request ? g_strdup(request) : NULL; | 3431 gfud->request = g_strdup(request); |
3437 gfud->include_headers = include_headers; | 3432 gfud->include_headers = include_headers; |
3438 | 3433 |
3439 gaim_url_parse(url, &gfud->website.address, &gfud->website.port, | 3434 gaim_url_parse(url, &gfud->website.address, &gfud->website.port, |
3440 &gfud->website.page, &gfud->website.user, &gfud->website.passwd); | 3435 &gfud->website.page, &gfud->website.user, &gfud->website.passwd); |
3441 | 3436 |
3675 | 3670 |
3676 utf8 = g_convert(str, -1, "UTF-8", "ISO-8859-15", &converted, NULL, NULL); | 3671 utf8 = g_convert(str, -1, "UTF-8", "ISO-8859-15", &converted, NULL, NULL); |
3677 if ((utf8 != NULL) && (converted == strlen(str))) | 3672 if ((utf8 != NULL) && (converted == strlen(str))) |
3678 return utf8; | 3673 return utf8; |
3679 | 3674 |
3680 if (utf8 != NULL) | 3675 g_free(utf8); |
3681 g_free(utf8); | |
3682 | 3676 |
3683 return NULL; | 3677 return NULL; |
3684 } | 3678 } |
3685 | 3679 |
3686 #define utf8_first(x) ((x & 0x80) == 0 || (x & 0xe0) == 0xc0 \ | 3680 #define utf8_first(x) ((x & 0x80) == 0 || (x & 0xe0) == 0xc0 \ |