From 6f8f41e20d791b16976d1a27a5a2dddc50a8cb6a Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 5 Nov 2006 04:21:52 +0000 Subject: [PATCH] decompress_data: change initial malloc size, drop init variable Adjust the size of to_read for the initial read instead of setting the init flag and using that later to check whether to read a smaller amount than the value in to_read. This also affects the realloc call on the initial read, which was allocating more memory than necessary (altho this discrepency would be corrected with the realloc for the next read). --- src/protocol/http/http.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 08b2e712..e3acc7fa 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -993,7 +993,6 @@ decompress_data(struct connection *conn, unsigned char *data, int len, do { int to_read; - int init = 0; if (state == NORMAL) { /* ... we aren't finishing yet. */ @@ -1037,14 +1036,17 @@ decompress_data(struct connection *conn, unsigned char *data, int len, if (!conn->stream) return NULL; /* On "startup" pipe is treated with care, but if everything * was already written to the pipe, caution isn't necessary */ - if (state != FINISHING) init = 1; + if (state != FINISHING) { + /* on init don't read too much */ + to_read = PIPE_BUF / 32; + } } output = (unsigned char *) mem_realloc(output, *new_len + to_read); if (!output) break; did_read = read_encoded(conn->stream, output + *new_len, - init ? PIPE_BUF / 32 : to_read); /* on init don't read too much */ + to_read); if (did_read > 0) *new_len += did_read; else if (did_read == -1) { mem_free_set(&output, NULL);