From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUgol-0007xj-Nh for qemu-devel@nongnu.org; Wed, 04 Feb 2009 07:25:24 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUgok-0007wB-H2 for qemu-devel@nongnu.org; Wed, 04 Feb 2009 07:25:22 -0500 Received: from [199.232.76.173] (port=39671 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUgoi-0007vc-Ma for qemu-devel@nongnu.org; Wed, 04 Feb 2009 07:25:20 -0500 Received: from mx2.redhat.com ([66.187.237.31]:56929) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUgoh-0007hu-Vo for qemu-devel@nongnu.org; Wed, 04 Feb 2009 07:25:20 -0500 From: Avi Kivity Date: Wed, 4 Feb 2009 14:25:12 +0200 Message-Id: <1233750314-23301-3-git-send-email-avi@redhat.com> In-Reply-To: <1233750314-23301-1-git-send-email-avi@redhat.com> References: <1233750314-23301-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] Add qemu_iovec_reset() Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Anthony Liguori Add a helper to zero out an existing iovec. Removes the need to deallocate and reallocate it. Signed-off-by: Avi Kivity --- cutils.c | 6 ++++++ qemu-common.h | 1 + 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/cutils.c b/cutils.c index 1090aa4..658746b 100644 --- a/cutils.c +++ b/cutils.c @@ -129,6 +129,12 @@ void qemu_iovec_destroy(QEMUIOVector *qiov) qemu_free(qiov->iov); } +void qemu_iovec_reset(QEMUIOVector *qiov) +{ + qiov->niov = 0; + qiov->size = 0; +} + void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf) { uint8_t *p = (uint8_t *)buf; diff --git a/qemu-common.h b/qemu-common.h index 8aef558..db33493 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -201,6 +201,7 @@ typedef struct QEMUIOVector { void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); void qemu_iovec_destroy(QEMUIOVector *qiov); +void qemu_iovec_reset(QEMUIOVector *qiov); void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf); void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count); -- 1.6.1.1