From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MHbeQ-0003wO-PD for qemu-devel@nongnu.org; Fri, 19 Jun 2009 06:48:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MHbeM-0003sw-IM for qemu-devel@nongnu.org; Fri, 19 Jun 2009 06:48:53 -0400 Received: from [199.232.76.173] (port=46789 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MHbeL-0003sk-3Y for qemu-devel@nongnu.org; Fri, 19 Jun 2009 06:48:49 -0400 Received: from mailgw3.cms.com ([202.75.200.223]:57578 helo=cms.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MHbeJ-0001dp-1n for qemu-devel@nongnu.org; Fri, 19 Jun 2009 06:48:48 -0400 Subject: Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem From: vibi sreenivasan In-Reply-To: <1245358219-13170-5-git-send-email-jcd@tribudubois.net> References: <1245358219-13170-1-git-send-email-jcd@tribudubois.net> <1245358219-13170-2-git-send-email-jcd@tribudubois.net> <1245358219-13170-3-git-send-email-jcd@tribudubois.net> <1245358219-13170-4-git-send-email-jcd@tribudubois.net> <1245358219-13170-5-git-send-email-jcd@tribudubois.net> Content-Type: text/plain Date: Fri, 19 Jun 2009 16:20:39 +0530 Message-Id: <1245408639.11443.13.camel@system> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Resent-Message-Id: Reply-To: vibi_sreenivasan@cms.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jean-Christophe DUBOIS Cc: qemu-devel@nongnu.org On Thu, 2009-06-18 at 22:50 +0200, Jean-Christophe DUBOIS wrote: > From: Jean-Christophe Dubois > > Signed-off-by: Jean-Christophe DUBOIS > --- > 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 __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 > {