From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38158 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUDYI-00077g-4u for qemu-devel@nongnu.org; Thu, 01 Jul 2010 02:47:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUDYG-0001Py-TI for qemu-devel@nongnu.org; Thu, 01 Jul 2010 02:47:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45205) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUDYG-0001Pu-KW for qemu-devel@nongnu.org; Thu, 01 Jul 2010 02:47:12 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o616lBsO018615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Jul 2010 02:47:11 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 2/3] blkdebug: Free QemuOpts after having read the config References: <1277912914-21771-1-git-send-email-kwolf@redhat.com> <1277912914-21771-3-git-send-email-kwolf@redhat.com> Date: Thu, 01 Jul 2010 08:47:09 +0200 In-Reply-To: <1277912914-21771-3-git-send-email-kwolf@redhat.com> (Kevin Wolf's message of "Wed, 30 Jun 2010 17:48:33 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org Kevin Wolf writes: > Forgetting to free them means that the next instance inherits all rules and > gets its own rules only additionally. I also found a use for freeing a complete QemuOptsList, here's my solution. The code that needs it isn't ready, yet. If you'd like to use it, I can push it to my repo. diff --git a/qemu-option.c b/qemu-option.c index 7f70d0f..30327d4 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -719,6 +719,15 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist return opts; } +void qemu_opts_reset(QemuOptsList *list) +{ + QemuOpts *opts, *next_opts; + + QTAILQ_FOREACH_SAFE(opts, &list->head, next, next_opts) { + qemu_opts_del(opts); + } +} + int qemu_opts_set(QemuOptsList *list, const char *id, const char *name, const char *value) { diff --git a/qemu-option.h b/qemu-option.h index 4823219..9e2406c 100644 --- a/qemu-option.h +++ b/qemu-option.h @@ -115,6 +115,7 @@ int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists); +void qemu_opts_reset(QemuOptsList *list); int qemu_opts_set(QemuOptsList *list, const char *id, const char *name, const char *value); const char *qemu_opts_id(QemuOpts *opts);