[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-use
From: |
vibi sreenivasan |
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 |
On Thu, 2009-06-18 at 22:50 +0200, Jean-Christophe DUBOIS wrote:
> From: Jean-Christophe Dubois <address@hidden(none)>
>
> Signed-off-by: Jean-Christophe DUBOIS <address@hidden>
> ---
> 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
> {
- [Qemu-devel] [PATCH v4 03/12] fix qemu_alloc/qemu_free for bsd-user subsystem, (continued)
- [Qemu-devel] [PATCH v4 03/12] fix qemu_alloc/qemu_free for bsd-user subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 05/12] fix qemu_alloc/qemu_free for target-i386 subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 06/12] fix qemu_alloc/qemu_free for slirp subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 07/12] fix qemu_alloc/qemu_free for audio subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 08/12] fix qemu_alloc/qemu_free for target-arm subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 09/12] fix qemu_alloc/qemu_free for target-ppc subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 10/12] fix qemu_alloc/qemu_free for target-sparc subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 11/12] fix qemu_alloc/qemu_free for tcg subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 12/12] fix qemu_alloc/qemu_free for main directory, Jean-Christophe DUBOIS, 2009/06/18
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem,
vibi sreenivasan <=
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Jean-Christophe Dubois, 2009/06/19
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, vibi sreenivasan, 2009/06/20
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Jean-Christophe Dubois, 2009/06/20
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Andreas Färber, 2009/06/20
Re: [Qemu-devel] [PATCH v4 01/12] fix qemu_alloc/qemu_free for block subsystem, Kevin Wolf, 2009/06/19