mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-17 21:26:13 -07:00
buffer: add buffer_move
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Peter Lieven <pl@kamp.de> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1446203414-4013-5-git-send-email-kraxel@redhat.com
This commit is contained in:
parent
4d1eb5fdb1
commit
830a958320
2 changed files with 26 additions and 0 deletions
|
|
@ -91,3 +91,19 @@ void buffer_move_empty(Buffer *to, Buffer *from)
|
|||
from->capacity = 0;
|
||||
from->buffer = NULL;
|
||||
}
|
||||
|
||||
void buffer_move(Buffer *to, Buffer *from)
|
||||
{
|
||||
if (to->offset == 0) {
|
||||
buffer_move_empty(to, from);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_reserve(to, from->offset);
|
||||
buffer_append(to, from->buffer, from->offset);
|
||||
|
||||
g_free(from->buffer);
|
||||
from->offset = 0;
|
||||
from->capacity = 0;
|
||||
from->buffer = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue