aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2012-07-24 14:24:08 +0200
committerJuan Quintela <quintela@redhat.com>2012-12-20 23:09:25 +0100
commitf50b4986b261fc10065289d2a03deba24d824988 (patch)
tree5f64215f6e0d14aa877bb2eef01712a672087e43
parentc518dd841deb85b3ccf77ff93e1142b27b06af32 (diff)
buffered_file: unfold buffered_append in buffered_put_buffer
It was the only user, and now buffered_put_buffer just do the append Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--buffered_file.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/buffered_file.c b/buffered_file.c
index 1d7fa2443d..be9424b543 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -41,22 +41,6 @@ typedef struct QEMUFileBuffered
do { } while (0)
#endif
-static void buffered_append(QEMUFileBuffered *s,
- const uint8_t *buf, size_t size)
-{
- if (size > (s->buffer_capacity - s->buffer_size)) {
- DPRINTF("increasing buffer capacity from %zu by %zu\n",
- s->buffer_capacity, size + 1024);
-
- s->buffer_capacity += size + 1024;
-
- s->buffer = g_realloc(s->buffer, s->buffer_capacity);
- }
-
- memcpy(s->buffer + s->buffer_size, buf, size);
- s->buffer_size += size;
-}
-
static ssize_t buffered_flush(QEMUFileBuffered *s)
{
size_t offset = 0;
@@ -101,11 +85,22 @@ static int buffered_put_buffer(void *opaque, const uint8_t *buf, int64_t pos, in
return error;
}
- if (size > 0) {
- DPRINTF("buffering %d bytes\n", size - offset);
- buffered_append(s, buf, size);
+ if (size <= 0) {
+ return size;
}
+ if (size > (s->buffer_capacity - s->buffer_size)) {
+ DPRINTF("increasing buffer capacity from %zu by %zu\n",
+ s->buffer_capacity, size + 1024);
+
+ s->buffer_capacity += size + 1024;
+
+ s->buffer = g_realloc(s->buffer, s->buffer_capacity);
+ }
+
+ memcpy(s->buffer + s->buffer_size, buf, size);
+ s->buffer_size += size;
+
return size;
}