From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Subject: [Qemu-devel] [PATCH 1/7] add qemu_memdup
Date: Sat, 17 Oct 2009 09:55:30 +0200 [thread overview]
Message-ID: <1255766136-3028-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1255766136-3028-1-git-send-email-pbonzini@redhat.com>
A nice-to-have utility function, it helps avoiding useless strlen+strdup
pairs.
Cc: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-common.h | 1 +
qemu-malloc.c | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/qemu-common.h b/qemu-common.h
index 820dd37..351f1ac 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -141,6 +141,7 @@ void *qemu_realloc(void *ptr, size_t size);
void *qemu_mallocz(size_t size);
void qemu_free(void *ptr);
char *qemu_strdup(const char *str);
+void *qemu_memdup(const void *str, size_t size);
char *qemu_strndup(const char *str, size_t size);
void *get_mmap_addr(unsigned long size);
diff --git a/qemu-malloc.c b/qemu-malloc.c
index 295d185..9e11e4b 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -70,6 +70,14 @@ void *qemu_mallocz(size_t size)
return ptr;
}
+void *qemu_memdup(const void *str, size_t n)
+{
+ char *ptr;
+ ptr = qemu_malloc(n);
+ memcpy(ptr, str, n);
+ return ptr;
+}
+
char *qemu_strdup(const char *str)
{
char *ptr;
--
1.6.2.5
next prev parent reply other threads:[~2009-10-17 7:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-17 7:55 [Qemu-devel] [PATCH 0/7] Add JSON enconding and formatted printing to QObject Paolo Bonzini
2009-10-17 7:55 ` Paolo Bonzini [this message]
2009-10-17 7:55 ` [Qemu-devel] [PATCH 2/7] allow passing NULL to qobject_type Paolo Bonzini
2009-10-17 7:55 ` [Qemu-devel] [PATCH 3/7] forward declare all QObject subclasses in qobject.h Paolo Bonzini
2009-10-17 13:02 ` Anthony Liguori
2009-10-17 7:55 ` [Qemu-devel] [PATCH 4/7] add mutable qstring functions Paolo Bonzini
2009-10-17 13:03 ` Anthony Liguori
2009-10-17 7:55 ` [Qemu-devel] [PATCH 5/7] add json encoder for qobjects Paolo Bonzini
2009-10-17 13:03 ` Anthony Liguori
2009-10-17 13:44 ` Paolo Bonzini
2009-10-17 16:20 ` Anthony Liguori
2009-10-17 7:55 ` [Qemu-devel] [PATCH 6/7] add testsuite for qobject json encoder Paolo Bonzini
2009-10-17 7:55 ` [Qemu-devel] [PATCH 7/7] add formatted printing of QObjects Paolo Bonzini
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=1255766136-3028-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=lcapitulino@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).