From: vibi sreenivasan <vibi_sreenivasan@cms.com>
To: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem
Date: Fri, 19 Jun 2009 16:20:39 +0530 [thread overview]
Message-ID: <1245408639.11443.13.camel@system> (raw)
In-Reply-To: <1245358219-13170-5-git-send-email-jcd@tribudubois.net>
On Thu, 2009-06-18 at 22:50 +0200, Jean-Christophe DUBOIS wrote:
> From: Jean-Christophe Dubois <jcd@jcd-laptop.(none)>
>
> Signed-off-by: Jean-Christophe DUBOIS <jcd@tribudubois.net>
> ---
> linux-user/main.c | 10 +++++-----
> linux-user/syscall.c | 16 ++++++++--------
> 2 files changed, 13 insertions(+), 13 deletions(-)
>
I can see an alternate implementation for
qemu_malloc & other related functions in linux-user/mmap.c
Thanks & Regards
Vibi Sreenivasan
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 7eabd0c..f90d844 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -2549,7 +2549,7 @@ int main(int argc, char **argv, char **envp)
> * Prepare copy of argv vector for target.
> */
> target_argc = argc - optind;
> - target_argv = calloc(target_argc + 1, sizeof (char *));
> + target_argv = qemu_mallocz((target_argc + 1) * sizeof (char *));
> if (target_argv == NULL) {
> (void) fprintf(stderr, "Unable to allocate memory for target_argv\n");
> exit(1);
> @@ -2583,15 +2583,15 @@ int main(int argc, char **argv, char **envp)
> }
>
> for (i = 0; i < target_argc; i++) {
> - free(target_argv[i]);
> + qemu_free(target_argv[i]);
> }
> - free(target_argv);
> + qemu_free(target_argv);
>
> for (wrk = target_environ; *wrk; wrk++) {
> - free(*wrk);
> + qemu_free(*wrk);
> }
>
> - free(target_environ);
> + qemu_free(target_environ);
>
> if (qemu_log_enabled()) {
> log_page_dump();
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 53a11ab..14df8aa 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2166,7 +2166,7 @@ static inline abi_long target_to_host_semarray(int semid, unsigned short **host_
>
> nsems = semid_ds.sem_nsems;
>
> - *host_array = malloc(nsems*sizeof(unsigned short));
> + *host_array = qemu_malloc(nsems*sizeof(unsigned short));
> array = lock_user(VERIFY_READ, target_addr,
> nsems*sizeof(unsigned short), 1);
> if (!array)
> @@ -2205,7 +2205,7 @@ static inline abi_long host_to_target_semarray(int semid, abi_ulong target_addr,
> for(i=0; i<nsems; i++) {
> __put_user((*host_array)[i], &array[i]);
> }
> - free(*host_array);
> + qemu_free(*host_array);
> unlock_user(array, target_addr, 1);
>
> return 0;
> @@ -2451,11 +2451,11 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
>
> if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
> return -TARGET_EFAULT;
> - host_mb = malloc(msgsz+sizeof(long));
> + host_mb = qemu_malloc(msgsz+sizeof(long));
> host_mb->mtype = (abi_long) tswapl(target_mb->mtype);
> memcpy(host_mb->mtext, target_mb->mtext, msgsz);
> ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
> - free(host_mb);
> + qemu_free(host_mb);
> unlock_user_struct(target_mb, msgp, 0);
>
> return ret;
> @@ -2473,7 +2473,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0))
> return -TARGET_EFAULT;
>
> - host_mb = malloc(msgsz+sizeof(long));
> + host_mb = qemu_malloc(msgsz+sizeof(long));
> ret = get_errno(msgrcv(msqid, host_mb, msgsz, tswapl(msgtyp), msgflg));
>
> if (ret > 0) {
> @@ -2488,7 +2488,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> }
>
> target_mb->mtype = tswapl(host_mb->mtype);
> - free(host_mb);
> + qemu_free(host_mb);
>
> end:
> if (target_mb)
> @@ -5756,7 +5756,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> struct linux_dirent *dirp;
> abi_long count = arg3;
>
> - dirp = malloc(count);
> + dirp = qemu_malloc(count);
> if (!dirp) {
> ret = -TARGET_ENOMEM;
> goto fail;
> @@ -5794,7 +5794,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> ret = count1;
> unlock_user(target_dirp, arg2, ret);
> }
> - free(dirp);
> + qemu_free(dirp);
> }
> #else
> {
next prev parent reply other threads:[~2009-06-19 10:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-18 20:50 [Qemu-devel] [PATCH v4 00/12] use qemu_malloc and friends consistently Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 01/12] fix qemu_alloc/qemu_free for block subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 02/12] fix qemu_alloc/qemu_free for hw subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 03/12] fix qemu_alloc/qemu_free for bsd-user subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 05/12] fix qemu_alloc/qemu_free for target-i386 subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 06/12] fix qemu_alloc/qemu_free for slirp subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 07/12] fix qemu_alloc/qemu_free for audio subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 08/12] fix qemu_alloc/qemu_free for target-arm subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 09/12] fix qemu_alloc/qemu_free for target-ppc subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 10/12] fix qemu_alloc/qemu_free for target-sparc subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 11/12] fix qemu_alloc/qemu_free for tcg subsystem Jean-Christophe DUBOIS
2009-06-18 20:50 ` [Qemu-devel] [PATCH v4 12/12] fix qemu_alloc/qemu_free for main directory Jean-Christophe DUBOIS
2013-10-19 5:26 ` [Qemu-devel] [PATCH v4 06/12] fix qemu_alloc/qemu_free for slirp subsystem Jan Kiszka
2009-06-19 10:50 ` vibi sreenivasan [this message]
2009-06-19 18:40 ` [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem Jean-Christophe Dubois
2009-06-20 7:01 ` vibi sreenivasan
2009-06-20 9:54 ` Jean-Christophe Dubois
2009-06-20 11:33 ` Andreas Färber
2009-06-19 8:07 ` [Qemu-devel] [PATCH v4 01/12] fix qemu_alloc/qemu_free for block subsystem 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=1245408639.11443.13.camel@system \
--to=vibi_sreenivasan@cms.com \
--cc=jcd@tribudubois.net \
--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).