From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LV0cc-0004PQ-8U for qemu-devel@nongnu.org; Thu, 05 Feb 2009 04:34:10 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LV0ca-0004NM-WE for qemu-devel@nongnu.org; Thu, 05 Feb 2009 04:34:09 -0500 Received: from [199.232.76.173] (port=58884 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LV0ca-0004Mu-6n for qemu-devel@nongnu.org; Thu, 05 Feb 2009 04:34:08 -0500 Received: from mx2.redhat.com ([66.187.237.31]:41891) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LV0cZ-0004F1-I6 for qemu-devel@nongnu.org; Thu, 05 Feb 2009 04:34:07 -0500 From: Avi Kivity Date: Thu, 5 Feb 2009 11:33:57 +0200 Message-Id: <1233826439-16856-3-git-send-email-avi@redhat.com> In-Reply-To: <1233826439-16856-1-git-send-email-avi@redhat.com> References: <1233826439-16856-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