Commit be959463afd3e257611d6b6ab98d24c0c94d4e3d

Authored by aliguori
1 parent 244ab90e

Add qemu_iovec_reset() (Avi Kivity)

Add a helper to zero out an existing iovec.  Removes the need to deallocate
and reallocate it.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6523 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 7 additions and 0 deletions
cutils.c
... ... @@ -129,6 +129,12 @@ void qemu_iovec_destroy(QEMUIOVector *qiov)
129 129 qemu_free(qiov->iov);
130 130 }
131 131  
  132 +void qemu_iovec_reset(QEMUIOVector *qiov)
  133 +{
  134 + qiov->niov = 0;
  135 + qiov->size = 0;
  136 +}
  137 +
132 138 void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf)
133 139 {
134 140 uint8_t *p = (uint8_t *)buf;
... ...
qemu-common.h
... ... @@ -201,6 +201,7 @@ typedef struct QEMUIOVector {
201 201 void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
202 202 void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
203 203 void qemu_iovec_destroy(QEMUIOVector *qiov);
  204 +void qemu_iovec_reset(QEMUIOVector *qiov);
204 205 void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf);
205 206 void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
206 207  
... ...