pidgin: a689900f: Minor cleanup. Should be no functionali...
markdoliner at pidgin.im
markdoliner at pidgin.im
Wed Nov 10 18:50:42 EST 2010
----------------------------------------------------------------------
Revision: a689900f924cb010bf0e9be671f2d51a66238c08
Parent: cc3c95af1aaf75f791f0540fe047da6650080bef
Author: markdoliner at pidgin.im
Date: 11/10/10 18:44:57
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a689900f924cb010bf0e9be671f2d51a66238c08
Changelog:
Minor cleanup. Should be no functionality change, just a variable
rename (tmp to end_of_headers) and always set body_len to
gfud->len - header_len (header_len should always be <= gfud->len)
Changes against parent cc3c95af1aaf75f791f0540fe047da6650080bef
patched libpurple/util.c
-------------- next part --------------
============================================================
--- libpurple/util.c 42a279dba6390bec6244be29da1f190669f927ad
+++ libpurple/util.c 18e5f025a96c5d59873d96ce8a6d6d6a12603968
@@ -3798,12 +3798,13 @@ url_fetch_recv_cb(gpointer url_data, gin
gfud->webdata[gfud->len] = '\0';
if(!gfud->got_headers) {
- char *tmp;
+ char *end_of_headers;
/* See if we've reached the end of the headers yet */
- if((tmp = strstr(gfud->webdata, "\r\n\r\n"))) {
- char * new_data;
- guint header_len = (tmp + 4 - gfud->webdata);
+ end_of_headers = strstr(gfud->webdata, "\r\n\r\n");
+ if (end_of_headers) {
+ char *new_data;
+ guint header_len = (end_of_headers + 4 - gfud->webdata);
size_t content_len;
purple_debug_misc("util", "Response headers: '%.*s'\n",
@@ -3819,7 +3820,7 @@ url_fetch_recv_cb(gpointer url_data, gin
content_len = parse_content_len(gfud->webdata, header_len);
gfud->chunked = content_is_chunked(gfud->webdata, header_len);
- if(content_len == 0) {
+ if (content_len == 0) {
/* We'll stick with an initial 8192 */
content_len = 8192;
} else {
@@ -3828,19 +3829,16 @@ url_fetch_recv_cb(gpointer url_data, gin
/* If we're returning the headers too, we don't need to clean them out */
- if(gfud->include_headers) {
+ if (gfud->include_headers) {
gfud->data_len = content_len + header_len;
gfud->webdata = g_realloc(gfud->webdata, gfud->data_len);
} else {
- size_t body_len = 0;
+ size_t body_len = gfud->len - header_len;
- if(gfud->len > (header_len))
- body_len = (gfud->len - header_len);
-
content_len = MAX(content_len, body_len);
new_data = g_try_malloc(content_len);
- if(new_data == NULL) {
+ if (new_data == NULL) {
purple_debug_error("util",
"Failed to allocate %" G_GSIZE_FORMAT " bytes: %s\n",
content_len, g_strerror(errno));
@@ -3854,9 +3852,8 @@ url_fetch_recv_cb(gpointer url_data, gin
}
/* We may have read part of the body when reading the headers, don't lose it */
- if(body_len > 0) {
- tmp += 4;
- memcpy(new_data, tmp, body_len);
+ if (body_len > 0) {
+ memcpy(new_data, end_of_headers + 4, body_len);
}
/* Out with the old... */
More information about the Commits
mailing list