summaryrefslogtreecommitdiff
path: root/src/http_chunk.c
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2015-02-08 19:10:44 +0000
committerStefan Bühler <stbuehler@web.de>2015-02-08 19:10:44 +0000
commitad3e93ea96d1cbaab00d07245dbd02f790060f85 (patch)
treeff1dab6ccb2f2cd95c2c668b290ed3b1ffc6022b /src/http_chunk.c
parentadfa06de996944b495b878540464dd6e74563052 (diff)
downloadlighttpd-git-ad3e93ea96d1cbaab00d07245dbd02f790060f85.tar.gz
Use buffer API to read and modify "used" member
- a lot of code tried to handle manually adding terminating zeroes and keeping track of the correct "used" count. Replaced all "external" usages with simple wrapper functions: * buffer_string_is_empty (used <= 1), buffer_is_empty (used == 0); prefer buffer_string_is_empty * buffer_string_set_length * buffer_string_length * CONST_BUF_LEN() macro - removed "static" buffer hacks (buffers pointing to constant/stack memory instead of malloc()ed data) - buffer_append_strftime(): refactor buffer+strftime uses - li_tohex(): no need for a buffer for binary-to-hex conversion: the output data length is easy to predict - remove "-Winline" from extra warnings: the "inline" keyword just supresses the warning about unused but defined (static) functions; don't care whether it actually gets inlined or not. From: Stefan Bühler <stbuehler@web.de> git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2979 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/http_chunk.c')
-rw-r--r--src/http_chunk.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/http_chunk.c b/src/http_chunk.c
index dd6a0433..79e4586a 100644
--- a/src/http_chunk.c
+++ b/src/http_chunk.c
@@ -42,8 +42,7 @@ static void http_chunk_append_len(server *srv, connection *con, size_t len) {
b->ptr[j] = (len & 0xf) + (((len & 0xf) <= 9) ? '0' : 'a' - 10);
len >>= 4;
}
- b->used = i;
- b->ptr[b->used++] = '\0';
+ buffer_commit(b, i);
buffer_append_string_len(b, CONST_STR_LEN("\r\n"));
}
@@ -82,7 +81,7 @@ void http_chunk_append_buffer(server *srv, connection *con, buffer *mem) {
cq = con->write_queue;
if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
- http_chunk_append_len(srv, con, mem->used - 1);
+ http_chunk_append_len(srv, con, buffer_string_length(mem));
}
chunkqueue_append_buffer(cq, mem);