From cb3017146d5322069fe4003ffcd4c9ada74dacb8 Mon Sep 17 00:00:00 2001 From: Krzysztof Krzyżaniak Date: Mon, 25 Sep 2006 08:27:05 +0000 Subject: eloy: new upstream version --- src/chunk.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/chunk.c') diff --git a/src/chunk.c b/src/chunk.c index 3903428..776d59e 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -194,6 +194,22 @@ int chunkqueue_append_buffer(chunkqueue *cq, buffer *mem) { return 0; } +int chunkqueue_append_buffer_weak(chunkqueue *cq, buffer *mem) { + chunk *c; + + if (mem->used == 0) return 0; + + c = chunkqueue_get_unused_chunk(cq); + c->type = MEM_CHUNK; + c->offset = 0; + if (c->mem) buffer_free(c->mem); + c->mem = mem; + + chunkqueue_append_chunk(cq, c); + + return 0; +} + int chunkqueue_prepend_buffer(chunkqueue *cq, buffer *mem) { chunk *c; @@ -209,6 +225,7 @@ int chunkqueue_prepend_buffer(chunkqueue *cq, buffer *mem) { return 0; } + int chunkqueue_append_mem(chunkqueue *cq, const char * mem, size_t len) { chunk *c; @@ -355,7 +372,7 @@ int chunkqueue_remove_finished_chunks(chunkqueue *cq) { switch (c->type) { case MEM_CHUNK: - if (c->offset == (off_t)c->mem->used - 1) is_finished = 1; + if (c->mem->used == 0 || (c->offset == (off_t)c->mem->used - 1)) is_finished = 1; break; case FILE_CHUNK: if (c->offset == c->file.length) is_finished = 1; -- cgit v1.2.3