aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2010-10-04 18:04:37 +0200
committermilo <milo@r0ot.me>2010-10-04 18:04:37 +0200
commit5a04b9ce287829abcce22a627c6b7fe46df3ec77 (patch)
treea81c2da470fc20997d8dd2f57ed612e74be48662
parent7b1359042c09e3f90f6d521e636c2d9123179912 (diff)
downloadlibssh-remote_wip.tar.gz
libssh-remote_wip.tar.xz
libssh-remote_wip.zip
Optimize buffer reallocationremote_wip
-rw-r--r--src/buffer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 27d2592..503a68b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -183,8 +183,10 @@ int buffer_add_data(struct ssh_buffer_struct *buffer, const void *data, uint32_t
if (buffer->allocated < (buffer->used + len)) {
if(buffer->pos > 0)
buffer_shift(buffer);
- if (realloc_buffer(buffer, buffer->used + len) < 0) {
- return -1;
+ if (buffer->allocated < (buffer->used + len)) {
+ if (realloc_buffer(buffer, buffer->used + len) < 0) {
+ return -1;
+ }
}
}