version 1.22, 2004/10/29 23:56:17 |
version 1.23, 2005/03/14 11:46:56 |
|
|
u_int newlen; |
u_int newlen; |
void *p; |
void *p; |
|
|
if (len > 0x100000) |
if (len > BUFFER_MAX_CHUNK) |
fatal("buffer_append_space: len %u not supported", len); |
fatal("buffer_append_space: len %u not supported", len); |
|
|
/* If the buffer is empty, start using it from the beginning. */ |
/* If the buffer is empty, start using it from the beginning. */ |
|
|
* If the buffer is quite empty, but all data is at the end, move the |
* If the buffer is quite empty, but all data is at the end, move the |
* data to the beginning and retry. |
* data to the beginning and retry. |
*/ |
*/ |
if (buffer->offset > buffer->alloc / 2) { |
if (buffer->offset > MIN(buffer->alloc, BUFFER_MAX_CHUNK)) { |
memmove(buffer->buf, buffer->buf + buffer->offset, |
memmove(buffer->buf, buffer->buf + buffer->offset, |
buffer->end - buffer->offset); |
buffer->end - buffer->offset); |
buffer->end -= buffer->offset; |
buffer->end -= buffer->offset; |
|
|
/* Increase the size of the buffer and retry. */ |
/* Increase the size of the buffer and retry. */ |
|
|
newlen = buffer->alloc + len + 32768; |
newlen = buffer->alloc + len + 32768; |
if (newlen > 0xa00000) |
if (newlen > BUFFER_MAX_LEN) |
fatal("buffer_append_space: alloc %u not supported", |
fatal("buffer_append_space: alloc %u not supported", |
newlen); |
newlen); |
buffer->buf = xrealloc(buffer->buf, newlen); |
buffer->buf = xrealloc(buffer->buf, newlen); |