qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 1/4] qemu-option: Don't reinvent append_option_parameters()
Date: Tue,  7 Dec 2010 09:35:53 +0000	[thread overview]
Message-ID: <1291714556-22961-2-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1291714556-22961-1-git-send-email-stefanha@linux.vnet.ibm.com>

parse_option_parameters() may need to create a new option parameter list
from a template list.  Use append_option_parameters() instead of
duplicating the code.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 qemu-option.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/qemu-option.c b/qemu-option.c
index 1f8f41a..e380fc1 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -416,20 +416,13 @@ QEMUOptionParameter *parse_option_parameters(const char *param,
     char value[256];
     char *param_delim, *value_delim;
     char next_delim;
-    size_t num_options;
 
     if (list == NULL) {
         return NULL;
     }
 
     if (dest == NULL) {
-        // Count valid options
-        num_options = count_option_parameters(list);
-
-        // Create a copy of the option list to fill in values
-        dest = qemu_mallocz((num_options + 1) * sizeof(QEMUOptionParameter));
-        allocated = dest;
-        memcpy(dest, list, (num_options + 1) * sizeof(QEMUOptionParameter));
+        dest = allocated = append_option_parameters(NULL, list);
     }
 
     while (*param) {
-- 
1.7.2.3

  reply	other threads:[~2010-12-07  9:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-07  9:35 [Qemu-devel] [PATCH 0/4] qemu-img: Fail creation if backing format is invalid Stefan Hajnoczi
2010-12-07  9:35 ` Stefan Hajnoczi [this message]
2010-12-07  9:35 ` [Qemu-devel] [PATCH 2/4] qemu-option: Fix parse_option_parameters() documentation typo Stefan Hajnoczi
2010-12-07  9:35 ` [Qemu-devel] [PATCH 3/4] qemu-img: Free option parameter lists in img_create() Stefan Hajnoczi
2010-12-07  9:35 ` [Qemu-devel] [PATCH 4/4] qemu-img: Fail creation if backing format is invalid Stefan Hajnoczi
2010-12-08  9:40 ` [Qemu-devel] Re: [PATCH 0/4] " Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291714556-22961-2-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).