Skip to content

Commit

Permalink
buffered_file: g_realloc() can't fail
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Quintela <quintela@redhat.com>

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
  • Loading branch information
Juan Quintela committed Oct 17, 2012
1 parent 6f4d6b0 commit 05e72dc
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions buffered_file.c
Expand Up @@ -50,20 +50,12 @@ static void buffered_append(QEMUFileBuffered *s,
const uint8_t *buf, size_t size)
{
if (size > (s->buffer_capacity - s->buffer_size)) {
void *tmp;

DPRINTF("increasing buffer capacity from %zu by %zu\n",
s->buffer_capacity, size + 1024);

s->buffer_capacity += size + 1024;

tmp = g_realloc(s->buffer, s->buffer_capacity);
if (tmp == NULL) {
fprintf(stderr, "qemu file buffer expansion failed\n");
exit(1);
}

s->buffer = tmp;
s->buffer = g_realloc(s->buffer, s->buffer_capacity);
}

memcpy(s->buffer + s->buffer_size, buf, size);
Expand Down

0 comments on commit 05e72dc

Please sign in to comment.