From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDPYS-0006wK-EP for qemu-devel@nongnu.org; Sun, 07 Jun 2009 17:05:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDPYN-0006tv-7D for qemu-devel@nongnu.org; Sun, 07 Jun 2009 17:05:24 -0400 Received: from [199.232.76.173] (port=43912 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDPYN-0006ts-20 for qemu-devel@nongnu.org; Sun, 07 Jun 2009 17:05:19 -0400 Received: from srv-05.w4a.fr ([94.23.5.116]:51153 helo=mx1.w4a.fr) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDPYM-0004h6-2C for qemu-devel@nongnu.org; Sun, 07 Jun 2009 17:05:18 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mx1.w4a.fr (Postfix) with ESMTP id 11E2513E31 for ; Sun, 7 Jun 2009 23:05:16 +0200 (CEST) Received: from mx1.w4a.fr ([127.0.0.1]) by localhost (mx1.w4a.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E0esc9yXg0IB for ; Sun, 7 Jun 2009 23:05:11 +0200 (CEST) Received: from mx1.w4a.fr (mx1.w4a.fr [91.121.53.100]) by mx1.w4a.fr (Postfix) with ESMTP id 9D86B13E25 for ; Sun, 7 Jun 2009 23:05:11 +0200 (CEST) Date: Sun, 7 Jun 2009 22:05:11 +0100 (GMT+01:00) From: jcd@tribudubois.net Message-ID: <3008498.87611244408711168.JavaMail.root@srv-05.w4a.fr> In-Reply-To: <200905292224.14770.jcd@tribudubois.net> Subject: Re: [Qemu-devel] [PATCH v2] use qemu_malloc and friends consistently MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hi, Just curious here, but will somebody pick up this patch at some point or do= I need to resubmit? It doesn't seem that the patch by itself is controversial even if the qemu_= malloc implementation issue is a heated discussion. Thanks JC ----- "Jean-Christophe Dubois" a =C3=A9crit : > qemu_malloc, qemu_free and friends are not used consistently in the > qemu=20 > source code. >=20 > This is a first attempt to use these oveloaded functions consistently > all over=20 > the place instead of the default glibc versions. >=20 > This version avoid to use qemu_malloc in qemu-io.c if the size to > allocate is=20 > 0. >=20 > Signed-off-by: Jean-Christophe DUBOIS >=20 > --- qemu.org/acl.c=09Sat May 16 17:57:26 2009 > +++ qemu/acl.c=09Thu May 28 23:14:01 2009 > @@ -104,8 +104,8 @@ > acl->defaultDeny =3D 1; > TAILQ_FOREACH(entry, &acl->entries, next) { > TAILQ_REMOVE(&acl->entries, entry, next); > - free(entry->match); > - free(entry); > + qemu_free(entry->match); > + qemu_free(entry); > } > acl->nentries =3D 0; > } > --- qemu.org/audio/paaudio.c=09Sat May 16 17:57:26 2009 > +++ qemu/audio/paaudio.c=09Thu May 28 23:14:01 2009 > @@ -340,7 +340,7 @@ > return 0; > =20 > fail3: > - free (pa->pcm_buf); > + qemu_free (pa->pcm_buf); > pa->pcm_buf =3D NULL; > fail2: > pa_simple_free (pa->s); > @@ -394,7 +394,7 @@ > return 0; > =20 > fail3: > - free (pa->pcm_buf); > + qemu_free (pa->pcm_buf); > pa->pcm_buf =3D NULL; > fail2: > pa_simple_free (pa->s); > --- qemu.org/block/cloop.c=09Sat May 16 17:57:26 2009 > +++ qemu/block/cloop.c=09Thu May 28 23:14:01 2009 > @@ -148,9 +148,9 @@ > BDRVCloopState *s =3D bs->opaque; > close(s->fd); > if(s->n_blocks>0) > -=09free(s->offsets); > - free(s->compressed_block); > - free(s->uncompressed_block); > +=09qemu_free(s->offsets); > + qemu_free(s->compressed_block); > + qemu_free(s->uncompressed_block); > inflateEnd(&s->zstream); > } > =20 > --- qemu.org/block/dmg.c=09Sat May 16 17:57:26 2009 > +++ qemu/block/dmg.c=09Thu May 28 23:14:01 2009 > @@ -273,14 +273,14 @@ > BDRVDMGState *s =3D bs->opaque; > close(s->fd); > if(s->n_chunks>0) { > -=09free(s->types); > -=09free(s->offsets); > -=09free(s->lengths); > -=09free(s->sectors); > -=09free(s->sectorcounts); > +=09qemu_free(s->types); > +=09qemu_free(s->offsets); > +=09qemu_free(s->lengths); > +=09qemu_free(s->sectors); > +=09qemu_free(s->sectorcounts); > } > - free(s->compressed_chunk); > - free(s->uncompressed_chunk); > + qemu_free(s->compressed_chunk); > + qemu_free(s->uncompressed_chunk); > inflateEnd(&s->zstream); > } > =20 > --- qemu.org/block/vvfat.c=09Sat May 16 17:57:26 2009 > +++ qemu/block/vvfat.c=09Thu May 28 23:14:01 2009 > @@ -87,7 +87,7 @@ > static inline void array_free(array_t* array) > { > if(array->pointer) > - free(array->pointer); > + qemu_free(array->pointer); > array->size=3Darray->next=3D0; > } > =20 > @@ -169,7 +169,7 @@ > =20 > memcpy(to,buf,is*count); > =20 > - free(buf); > + qemu_free(buf); > =20 > return 0; > } > @@ -732,7 +732,7 @@ > =09snprintf(buffer,length,"%s/%s",dirname,entry->d_name); > =20 > =09if(stat(buffer,&st)<0) { > -=09 free(buffer); > +=09 qemu_free(buffer); > continue; > =09} > =20 > @@ -755,7 +755,7 @@ > =09 direntry->begin=3D0; /* do that later */ > if (st.st_size > 0x7fffffff) { > =09 fprintf(stderr, "File %s is larger than 2GB\n", buffer); > -=09 free(buffer); > +=09 qemu_free(buffer); > =09 return -2; > } > =09direntry->size=3Dcpu_to_le32(S_ISDIR(st.st_mode)?0:st.st_size); > @@ -882,7 +882,7 @@ > mapping->dir_index =3D 0; > mapping->info.dir.parent_mapping_index =3D -1; > mapping->first_mapping_index =3D -1; > - mapping->path =3D strdup(dirname); > + mapping->path =3D qemu_strdup(dirname); > i =3D strlen(mapping->path); > if (i > 0 && mapping->path[i - 1] =3D=3D '/') > =09mapping->path[i - 1] =3D '\0'; > @@ -1369,7 +1369,7 @@ > =09assert(commit->path || commit->action =3D=3D ACTION_WRITEOUT); > =09if (commit->action !=3D ACTION_WRITEOUT) { > =09 assert(commit->path); > -=09 free(commit->path); > +=09 qemu_free(commit->path); > =09} else > =09 assert(commit->path =3D=3D NULL); > } > @@ -1632,10 +1632,10 @@ > =20 > =09 /* rename */ > =09 if (strcmp(basename, basename2)) > -=09=09schedule_rename(s, cluster_num, strdup(path)); > +=09=09schedule_rename(s, cluster_num, qemu_strdup(path)); > =09} else if (is_file(direntry)) > =09 /* new file */ > -=09 schedule_new_file(s, strdup(path), cluster_num); > +=09 schedule_new_file(s, qemu_strdup(path), cluster_num); > =09else { > =09 assert(0); > =09 return 0; > @@ -1752,10 +1752,10 @@ > =09mapping->mode &=3D ~MODE_DELETED; > =20 > =09if (strcmp(basename, basename2)) > -=09 schedule_rename(s, cluster_num, strdup(path)); > +=09 schedule_rename(s, cluster_num, qemu_strdup(path)); > } else > =09/* new directory */ > -=09schedule_mkdir(s, cluster_num, strdup(path)); > +=09schedule_mkdir(s, cluster_num, qemu_strdup(path)); > =20 > lfn_init(&lfn); > do { > @@ -1776,7 +1776,7 @@ > =09if (subret) { > =09 fprintf(stderr, "Error fetching direntries\n"); > =09fail: > -=09 free(cluster); > +=09 qemu_free(cluster); > =09 return 0; > =09} > =20 > @@ -1844,7 +1844,7 @@ > =09cluster_num =3D modified_fat_get(s, cluster_num); > } while(!fat_eof(s, cluster_num)); > =20 > - free(cluster); > + qemu_free(cluster); > return ret; > } > =20 > @@ -1990,7 +1990,7 @@ > =20 > /* free mapping */ > if (mapping->first_mapping_index < 0) > -=09free(mapping->path); > +=09qemu_free(mapping->path); > =20 > /* remove from s->mapping */ > array_remove(&(s->mapping), mapping_index); > @@ -2390,7 +2390,7 @@ > =09=09} > =09 } > =20 > -=09 free(old_path); > +=09 qemu_free(old_path); > =09 array_remove(&(s->commits), i); > =09 continue; > =09} else if (commit->action =3D=3D ACTION_MKDIR) { > @@ -2758,7 +2758,7 @@ > static void write_target_close(BlockDriverState *bs) { > BDRVVVFATState* s =3D bs->opaque; > bdrv_delete(s->qcow); > - free(s->qcow_filename); > + qemu_free(s->qcow_filename); > } > =20 > static BlockDriver vvfat_write_target =3D { > @@ -2771,7 +2771,7 @@ > static int enable_write_target(BDRVVVFATState *s) > { > int size =3D sector2cluster(s, s->sector_count); > - s->used_clusters =3D calloc(size, 1); > + s->used_clusters =3D qemu_mallocz(size); > =20 > array_init(&(s->commits), sizeof(commit_t)); > =20 > @@ -2788,7 +2788,7 @@ > unlink(s->qcow_filename); > #endif > =20 > - s->bs->backing_hd =3D calloc(sizeof(BlockDriverState), 1); > + s->bs->backing_hd =3D qemu_mallocz(sizeof(BlockDriverState)); > s->bs->backing_hd->drv =3D &vvfat_write_target; > s->bs->backing_hd->opaque =3D s; > =20 > @@ -2804,7 +2804,7 @@ > array_free(&(s->directory)); > array_free(&(s->mapping)); > if(s->cluster_buffer) > - free(s->cluster_buffer); > + qemu_free(s->cluster_buffer); > } > =20 > static BlockDriver bdrv_vvfat =3D { > --- qemu.org/bsd-user/main.c=09Sat May 16 17:57:26 2009 > +++ qemu/bsd-user/main.c=09Thu May 28 23:14:01 2009 > @@ -822,7 +822,7 @@ > while (*(wrk++)) > environ_count++; > =20 > - target_environ =3D malloc((environ_count + 1) * sizeof(char *)); > + target_environ =3D qemu_malloc((environ_count + 1) * sizeof(char > *)); > if (!target_environ) > abort(); > for (wrk =3D environ, dst =3D target_environ; *wrk; wrk++) { > @@ -838,10 +838,10 @@ > } > =20 > for (wrk =3D target_environ; *wrk; wrk++) { > - free(*wrk); > + qemu_free(*wrk); > } > =20 > - free(target_environ); > + qemu_free(target_environ); > =20 > if (qemu_log_enabled()) { > log_page_dump(); > --- qemu.org/bsd-user/path.c=09Sat May 16 17:57:26 2009 > +++ qemu/bsd-user/path.c=09Thu May 28 23:14:01 2009 > @@ -45,8 +45,8 @@ > struct pathelem *parent, > const char *name) > { > - struct pathelem *new =3D malloc(sizeof(*new)); > - new->name =3D strdup(name); > + struct pathelem *new =3D qemu_malloc(sizeof(*new)); > + new->name =3D qemu_strdup(name); > asprintf(&new->pathname, "%s/%s", root, name); > new->num_entries =3D 0; > return new; > @@ -75,7 +75,7 @@ > { > root->num_entries++; > =20 > - root =3D realloc(root, sizeof(*root) > + root =3D qemu_realloc(root, sizeof(*root) > + sizeof(root->entries[0])*root->num_entries); > =20 > root->entries[root->num_entries-1] =3D new_entry(root->pathname, > root,=20 > name); > @@ -137,14 +137,14 @@ > pstrcpy(pref_buf, sizeof(pref_buf), cwd); > pstrcat(pref_buf, pref_buf_len, "/"); > pstrcat(pref_buf, pref_buf_len, prefix); > - free(cwd); > + qemu_free(cwd); > } else > pstrcpy(pref_buf, sizeof(pref_buf), prefix + 1); > =20 > base =3D new_entry("", NULL, pref_buf); > base =3D add_dir_maybe(base); > if (base->num_entries =3D=3D 0) { > - free (base); > + qemu_free (base); > base =3D NULL; > } else { > set_parents(base, base); > --- qemu.org/hw/baum.c=09Sat May 16 17:57:26 2009 > +++ qemu/hw/baum.c=09Thu May 28 23:14:01 2009 > @@ -558,7 +558,7 @@ > if (ret =3D=3D -1 && (brlapi_errno !=3D BRLAPI_ERROR_LIBCERR || errn= o > !=3D=20 > EINTR)) { > brlapi_perror("baum: brlapi_readKey"); > brlapi__closeConnection(baum->brlapi); > - free(baum->brlapi); > + qemu_free(baum->brlapi); > baum->brlapi =3D NULL; > } > } > @@ -621,9 +621,9 @@ > qemu_free_timer(baum->cellCount_timer); > brlapi__closeConnection(handle); > fail_handle: > - free(handle); > - free(chr); > - free(baum); > + qemu_free(handle); > + qemu_free(chr); > + qemu_free(baum); > return NULL; > } > =20 > --- qemu.org/hw/bt-l2cap.c=09Sat May 16 17:57:26 2009 > +++ qemu/hw/bt-l2cap.c=09Thu May 28 23:14:01 2009 > @@ -1220,7 +1220,7 @@ > for (cid =3D L2CAP_CID_ALLOC; cid < L2CAP_CID_MAX; cid ++) > if (l2cap->cid[cid]) { > =20 > l2cap->cid[cid]->params.close(l2cap->cid[cid]->params.opaque); > - free(l2cap->cid[cid]); > + qemu_free(l2cap->cid[cid]); > } > =20 > if (l2cap->role) > --- qemu.org/hw/nseries.c=09Sat May 16 17:57:26 2009 > +++ qemu/hw/nseries.c=09Thu May 28 23:14:02 2009 > @@ -711,7 +711,7 @@ > fb_blank =3D memset(qemu_malloc(800 * 480 * 2), 0xff, 800 * 480 * > 2); > /* Display Memory Data Port */ > chip->block(chip->opaque, 1, fb_blank, 800 * 480 * 2, 800); > - free(fb_blank); > + qemu_free(fb_blank); > } > =20 > static void n8x0_dss_setup(struct n800_s *s) > --- qemu.org/hw/ppc440_bamboo.c=09Sat May 16 17:57:26 2009 > +++ qemu/hw/ppc440_bamboo.c=09Thu May 28 23:14:02 2009 > @@ -45,7 +45,7 @@ > snprintf(path, pathlen, "%s/%s", bios_dir, > BINARY_DEVICE_TREE_FILE); > =20 > fdt =3D load_device_tree(path, &fdt_size); > - free(path); > + qemu_free(path); > if (fdt =3D=3D NULL) > goto out; > =20 > --- qemu.org/hw/scsi-generic.c=09Sat May 16 17:57:26 2009 > +++ qemu/hw/scsi-generic.c=09Thu May 28 23:14:02 2009 > @@ -564,7 +564,7 @@ > =20 > if (len =3D=3D 0) { > if (r->buf !=3D NULL) > - free(r->buf); > + qemu_free(r->buf); > r->buflen =3D 0; > r->buf =3D NULL; > ret =3D execute_command(s->bdrv, r, SG_DXFER_NONE,=20 > scsi_command_complete); > @@ -577,7 +577,7 @@ > =20 > if (r->buflen !=3D len) { > if (r->buf !=3D NULL) > - free(r->buf); > + qemu_free(r->buf); > r->buf =3D qemu_malloc(len); > r->buflen =3D len; > } > --- qemu.org/linux-user/main.c=09Sat May 16 17:57:26 2009 > +++ qemu/linux-user/main.c=09Thu May 28 23:14:02 2009 > @@ -2464,7 +2464,7 @@ > * Prepare copy of argv vector for target. > */ > target_argc =3D argc - optind; > - target_argv =3D calloc(target_argc + 1, sizeof (char *)); > + target_argv =3D qemu_mallocz((target_argc + 1) * sizeof (char *)); > if (target_argv =3D=3D NULL) { > =09(void) fprintf(stderr, "Unable to allocate memory for > target_argv\n"); > =09exit(1); > @@ -2489,15 +2489,15 @@ > } > =20 > for (i =3D 0; i < target_argc; i++) { > - free(target_argv[i]); > + qemu_free(target_argv[i]); > } > - free(target_argv); > + qemu_free(target_argv); > =20 > for (wrk =3D target_environ; *wrk; wrk++) { > - free(*wrk); > + qemu_free(*wrk); > } > =20 > - free(target_environ); > + qemu_free(target_environ); > =20 > if (qemu_log_enabled()) { > log_page_dump(); > --- qemu.org/linux-user/syscall.c=09Sat May 16 17:57:26 2009 > +++ qemu/linux-user/syscall.c=09Thu May 28 23:14:02 2009 > @@ -2094,7 +2094,7 @@ > =20 > nsems =3D semid_ds.sem_nsems; > =20 > - *host_array =3D malloc(nsems*sizeof(unsigned short)); > + *host_array =3D qemu_malloc(nsems*sizeof(unsigned short)); > array =3D lock_user(VERIFY_READ, target_addr, > nsems*sizeof(unsigned short), 1); > if (!array) > @@ -2133,7 +2133,7 @@ > for(i=3D0; i __put_user((*host_array)[i], &array[i]); > } > - free(*host_array); > + qemu_free(*host_array); > unlock_user(array, target_addr, 1); > =20 > return 0; > @@ -2379,11 +2379,11 @@ > =20 > if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0)) > return -TARGET_EFAULT; > - host_mb =3D malloc(msgsz+sizeof(long)); > + host_mb =3D qemu_malloc(msgsz+sizeof(long)); > host_mb->mtype =3D (abi_long) tswapl(target_mb->mtype); > memcpy(host_mb->mtext, target_mb->mtext, msgsz); > ret =3D get_errno(msgsnd(msqid, host_mb, msgsz, msgflg)); > - free(host_mb); > + qemu_free(host_mb); > unlock_user_struct(target_mb, msgp, 0); > =20 > return ret; > @@ -2401,7 +2401,7 @@ > if (!lock_user_struct(VERIFY_WRITE, target_mb, msgp, 0)) > return -TARGET_EFAULT; > =20 > - host_mb =3D malloc(msgsz+sizeof(long)); > + host_mb =3D qemu_malloc(msgsz+sizeof(long)); > ret =3D get_errno(msgrcv(msqid, host_mb, msgsz, tswapl(msgtyp), > msgflg)); > =20 > if (ret > 0) { > @@ -2416,7 +2416,7 @@ > } > =20 > target_mb->mtype =3D tswapl(host_mb->mtype); > - free(host_mb); > + qemu_free(host_mb); > =20 > end: > if (target_mb) > @@ -5428,7 +5428,7 @@ > struct linux_dirent *dirp; > abi_long count =3D arg3; > =20 > -=09 dirp =3D malloc(count); > +=09 dirp =3D qemu_malloc(count); > =09 if (!dirp) { > ret =3D -TARGET_ENOMEM; > goto fail; > @@ -5466,7 +5466,7 @@ > =09=09ret =3D count1; > unlock_user(target_dirp, arg2, ret); > } > -=09 free(dirp); > +=09 qemu_free(dirp); > } > #else > { > --- qemu.org/migration.c=09Sat May 16 17:57:27 2009 > +++ qemu/migration.c=09Thu May 28 23:14:02 2009 > @@ -266,7 +266,7 @@ > s->state =3D MIG_STATE_CANCELLED; > migrate_fd_cleanup(s); > } > - free(s); > + qemu_free(s); > } > =20 > void migrate_fd_wait_for_unfreeze(void *opaque) > --- qemu.org/net.c=09Sat May 16 17:57:27 2009 > +++ qemu/net.c=09Thu May 28 23:14:02 2009 > @@ -214,7 +214,7 @@ > struct sockaddr_in *saddr, > const char *input_str) > { > - char *str =3D strdup(input_str); > + char *str =3D qemu_strdup(input_str); > char *host_str =3D str; > char *src_str; > const char *src_str2; > @@ -243,11 +243,11 @@ > if (parse_host_port(saddr, src_str2) < 0) > goto fail; > =20 > - free(str); > + qemu_free(str); > return(0); > =20 > fail: > - free(str); > + qemu_free(str); > return -1; > } > =20 > @@ -326,7 +326,7 @@ > =20 > snprintf(buf, sizeof(buf), "%s.%d", model, id); > =20 > - return strdup(buf); > + return qemu_strdup(buf); > } > =20 > VLANClientState *qemu_new_vlan_client(VLANState *vlan, > @@ -339,9 +339,9 @@ > { > VLANClientState *vc, **pvc; > vc =3D qemu_mallocz(sizeof(VLANClientState)); > - vc->model =3D strdup(model); > + vc->model =3D qemu_strdup(model); > if (name) > - vc->name =3D strdup(name); > + vc->name =3D qemu_strdup(name); > else > vc->name =3D assign_name(vc, model); > vc->fd_read =3D fd_read; > @@ -368,8 +368,8 @@ > if (vc->cleanup) { > vc->cleanup(vc); > } > - free(vc->name); > - free(vc->model); > + qemu_free(vc->name); > + qemu_free(vc->model); > qemu_free(vc); > break; > } else > @@ -1147,7 +1147,7 @@ > s =3D qemu_mallocz(sizeof(VDEState)); > s->vde =3D vde_open(init_sock, (char *)"QEMU", &args); > if (!s->vde){ > - free(s); > + qemu_free(s); > return -1; > } > s->vc =3D qemu_new_vlan_client(vlan, model, name, vde_from_qemu, > @@ -1515,8 +1515,8 @@ > return -1; > } > s->vlan =3D vlan; > - s->model =3D strdup(model); > - s->name =3D name ? strdup(name) : NULL; > + s->model =3D qemu_strdup(model); > + s->name =3D name ? qemu_strdup(name) : NULL; > s->fd =3D fd; > qemu_set_fd_handler(fd, net_socket_accept, NULL, s); > return 0; > @@ -1746,7 +1746,7 @@ > int i, exit_status =3D 0; > =20 > if (!nd->model) > - nd->model =3D strdup(default_model); > + nd->model =3D qemu_strdup(default_model); > =20 > if (strcmp(nd->model, "?") !=3D 0) { > for (i =3D 0 ; models[i]; i++) > @@ -1781,7 +1781,7 @@ > vlan =3D qemu_find_vlan(vlan_id); > =20 > if (get_param_value(buf, sizeof(buf), "name", p)) { > - name =3D strdup(buf); > + name =3D qemu_strdup(buf); > } > if (!strcmp(device, "nic")) { > static const char * const nic_params[] =3D { > @@ -1818,7 +1818,7 @@ > } > } > if (get_param_value(buf, sizeof(buf), "model", p)) { > - nd->model =3D strdup(buf); > + nd->model =3D qemu_strdup(buf); > } > nd->vlan =3D vlan; > nd->name =3D name; > @@ -1854,7 +1854,7 @@ > slirp_restrict =3D (buf[0] =3D=3D 'y') ? 1 : 0; > } > if (get_param_value(buf, sizeof(buf), "ip", p)) { > - slirp_ip =3D strdup(buf); > + slirp_ip =3D qemu_strdup(buf); > } > vlan->nb_host_devs++; > ret =3D net_slirp_init(vlan, device, name); > @@ -1870,7 +1870,7 @@ > ret =3D -1; > goto out; > } > - vmc =3D malloc(sizeof(struct VMChannel)); > + vmc =3D qemu_malloc(sizeof(struct VMChannel)); > snprintf(name, 20, "vmchannel%ld", port); > vmc->hd =3D qemu_chr_open(name, devname, NULL); > if (!vmc->hd) { > @@ -2047,7 +2047,7 @@ > } > out: > if (name) > - free(name); > + qemu_free(name); > return ret; > } > =20 > @@ -2056,7 +2056,7 @@ > nd->vlan->nb_guest_devs--; > nb_nics--; > nd->used =3D 0; > - free((void *)nd->model); > + qemu_free((void *)nd->model); > } > =20 > static int net_host_check_device(const char *device) > --- qemu.org/qemu-char.c=09Sat May 16 17:57:27 2009 > +++ qemu/qemu-char.c=09Thu May 28 23:14:02 2009 > @@ -1553,8 +1553,8 @@ > chr->chr_close =3D win_chr_close; > =20 > if (win_chr_init(chr, filename) < 0) { > - free(s); > - free(chr); > + qemu_free(s); > + qemu_free(chr); > return NULL; > } > qemu_chr_reset(chr); > @@ -1652,8 +1652,8 @@ > chr->chr_close =3D win_chr_close; > =20 > if (win_chr_pipe_init(chr, filename) < 0) { > - free(s); > - free(chr); > + qemu_free(s); > + qemu_free(chr); > return NULL; > } > qemu_chr_reset(chr); > @@ -1808,9 +1808,9 @@ > =20 > return_err: > if (chr) > - free(chr); > + qemu_free(chr); > if (s) > - free(s); > + qemu_free(s); > if (fd >=3D 0) > closesocket(fd); > return NULL; > --- qemu.org/qemu-img.c=09Sat May 16 17:57:27 2009 > +++ qemu/qemu-img.c=09Thu May 28 23:14:02 2009 > @@ -696,7 +696,7 @@ > bdrv_delete(out_bs); > for (bs_i =3D 0; bs_i < bs_n; bs_i++) > bdrv_delete(bs[bs_i]); > - free(bs); > + qemu_free(bs); > return 0; > } > =20 > --- qemu.org/qemu-io.c=09Sat May 16 17:57:27 2009 > +++ qemu/qemu-io.c=09Fri May 29 19:45:51 2009 > @@ -310,15 +310,15 @@ > =09=09return 0; > =09} > =20 > -=09if (Pflag) { > -=09=09void* cmp_buf =3D malloc(pattern_count); > +=09if (Pflag && pattern_count) { > +=09=09void* cmp_buf =3D qemu_malloc(pattern_count); > =09=09memset(cmp_buf, pattern, pattern_count); > =09=09if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { > =09=09=09printf("Pattern verification failed at offset %lld, " > =09=09=09=09"%d bytes\n", > =09=09=09=09(long long) offset + pattern_offset, pattern_count); > =09=09} > -=09=09free(cmp_buf); > +=09=09qemu_free(cmp_buf); > =09} > =20 > =09if (qflag) > @@ -464,15 +464,15 @@ > =09=09return 0; > =09} > =20 > -=09if (Pflag) { > -=09=09void* cmp_buf =3D malloc(count); > +=09if (Pflag && count) { > +=09=09void* cmp_buf =3D qemu_malloc(count); > =09=09memset(cmp_buf, pattern, count); > =09=09if (memcmp(buf, cmp_buf, count)) { > =09=09=09printf("Pattern verification failed at offset %lld, " > =09=09=09=09"%d bytes\n", > =09=09=09=09(long long) offset, count); > =09=09} > -=09=09free(cmp_buf); > +=09=09qemu_free(cmp_buf); > =09} > =20 > =09if (qflag) > --- qemu.org/readline.c=09Sat May 16 17:57:27 2009 > +++ qemu/readline.c=09Thu May 28 23:14:02 2009 > @@ -246,7 +246,7 @@ > } > if (idx =3D=3D READLINE_MAX_CMDS) { > =09/* Need to get one free slot */ > -=09free(rs->history[0]); > +=09qemu_free(rs->history[0]); > =09memcpy(rs->history, &rs->history[1], > =09 (READLINE_MAX_CMDS - 1) * sizeof(char *)); > =09rs->history[READLINE_MAX_CMDS - 1] =3D NULL; > --- qemu.org/slirp/socket.c=09Sat May 16 17:57:27 2009 > +++ qemu/slirp/socket.c=09Thu May 28 23:14:02 2009 > @@ -53,7 +53,7 @@ > { > struct socket *so; > =20 > - so =3D (struct socket *)malloc(sizeof(struct socket)); > + so =3D (struct socket *)qemu_malloc(sizeof(struct socket)); > if(so) { > memset(so, 0, sizeof(struct socket)); > so->so_state =3D SS_NOFDREF; > @@ -82,7 +82,7 @@ > if(so->so_next && so->so_prev) > remque(so); /* crashes if so is not in a queue */ > =20 > - free(so); > + qemu_free(so); > } > =20 > size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np) > @@ -601,13 +601,13 @@ > =09DEBUG_ARG("flags =3D %x", flags); > =20 > =09if ((so =3D socreate()) =3D=3D NULL) { > -=09 /* free(so); Not sofree() ??? free(NULL) =3D=3D NOP */ > +=09 /* qemu_free(so); Not sofree() ??? qemu_free(NULL) =3D=3D NOP = */ > =09 return NULL; > =09} > =20 > =09/* Don't tcp_attach... we don't need so_snd nor so_rcv */ > =09if ((so->so_tcpcb =3D tcp_newtcpcb(so)) =3D=3D NULL) { > -=09=09free(so); > +=09=09qemu_free(so); > =09=09return NULL; > =09} > =09insque(so,&tcb); > --- qemu.org/target-arm/helper.c=09Sat May 16 17:57:27 2009 > +++ qemu/target-arm/helper.c=09Thu May 28 23:14:02 2009 > @@ -330,7 +330,7 @@ > =20 > void cpu_arm_close(CPUARMState *env) > { > - free(env); > + qemu_free(env); > } > =20 > uint32_t cpsr_read(CPUARMState *env) > @@ -466,7 +466,7 @@ > =20 > static void allocate_mmon_state(CPUState *env) > { > - env->mmon_entry =3D malloc(sizeof (mmon_state)); > + env->mmon_entry =3D qemu_malloc(sizeof (mmon_state)); > memset (env->mmon_entry, 0, sizeof (mmon_state)); > env->mmon_entry->cpu_env =3D env; > mmon_head =3D env->mmon_entry; > --- qemu.org/target-i386/helper.c=09Sat May 16 17:57:27 2009 > +++ qemu/target-i386/helper.c=09Thu May 28 23:14:02 2009 > @@ -397,11 +397,11 @@ > x86_cpu_def->ext_features &=3D ~minus_ext_features; > x86_cpu_def->ext2_features &=3D ~minus_ext2_features; > x86_cpu_def->ext3_features &=3D ~minus_ext3_features; > - free(s); > + qemu_free(s); > return 0; > =20 > error: > - free(s); > + qemu_free(s); > return -1; > } > =20 > --- qemu.org/target-i386/kvm.c=09Sat May 16 17:57:27 2009 > +++ qemu/target-i386/kvm.c=09Thu May 28 23:14:02 2009 > @@ -224,7 +224,7 @@ > } > } > =20 > - free(kvm_msr_list); > + qemu_free(kvm_msr_list); > } > =20 > if (has_msr_star =3D=3D 1) > --- qemu.org/target-ppc/kvm_ppc.c=09Sat May 16 17:57:27 2009 > +++ qemu/target-ppc/kvm_ppc.c=09Thu May 28 23:14:02 2009 > @@ -51,7 +51,7 @@ > close: > fclose(f); > free: > - free(path); > + qemu_free(path); > out: > return ret; > } > --- qemu.org/target-sparc/helper.c=09Sat May 16 17:57:27 2009 > +++ qemu/target-sparc/helper.c=09Thu May 28 23:14:02 2009 > @@ -706,8 +706,8 @@ > =20 > static void cpu_sparc_close(CPUSPARCState *env) > { > - free(env->def); > - free(env); > + qemu_free(env->def); > + qemu_free(env); > } > =20 > CPUSPARCState *cpu_sparc_init(const char *cpu_model) > @@ -1333,11 +1333,11 @@ > #ifdef DEBUG_FEATURES > print_features(stderr, fprintf, cpu_def->features, NULL); > #endif > - free(s); > + qemu_free(s); > return 0; > =20 > error: > - free(s); > + qemu_free(s); > return -1; > } > =20 > --- qemu.org/tcg/tcg.c=09Sat May 16 17:57:27 2009 > +++ qemu/tcg/tcg.c=09Thu May 28 23:14:02 2009 > @@ -341,7 +341,7 @@ > #endif > pstrcpy(buf, sizeof(buf), name); > pstrcat(buf, sizeof(buf), "_0"); > - ts->name =3D strdup(buf); > + ts->name =3D qemu_strdup(buf); > ts++; > =20 > ts->base_type =3D type; > @@ -356,7 +356,7 @@ > #endif > pstrcpy(buf, sizeof(buf), name); > pstrcat(buf, sizeof(buf), "_1"); > - ts->name =3D strdup(buf); > + ts->name =3D qemu_strdup(buf); > =20 > s->nb_globals +=3D 2; > } else > @@ -531,7 +531,7 @@ > } else { > n *=3D 2; > } > - s->helpers =3D realloc(s->helpers, n * sizeof(TCGHelperInfo)); > + s->helpers =3D qemu_realloc(s->helpers, n * > sizeof(TCGHelperInfo)); > s->allocated_helpers =3D n; > } > s->helpers[s->nb_helpers].func =3D (tcg_target_ulong)func; > --- qemu.org/vl.c=09Sat May 16 17:57:27 2009 > +++ qemu/vl.c=09Thu May 28 23:14:03 2009 > @@ -1071,7 +1071,7 @@ > exit(0); > } > =20 > - arg =3D strdup(opt); > + arg =3D qemu_strdup(opt); > =20 > /* Reorder the array */ > name =3D strtok(arg, ","); > @@ -1100,7 +1100,7 @@ > name =3D strtok(NULL, ","); > } > =20 > - free(arg); > + qemu_free(arg); > =20 > if (cur) { > /* Disable remaining timers */ > @@ -5711,7 +5716,7 @@ > fprintf(stderr, "Too many option ROMs\n"); > exit(1); > } > - option_rom[nb_option_roms] =3D strdup(buf); > + option_rom[nb_option_roms] =3D qemu_strdup(buf); > nb_option_roms++; > netroms++; > } > --- qemu.org/vnc-auth-sasl.c=09Sat May 16 17:57:27 2009 > +++ qemu/vnc-auth-sasl.c=09Thu May 28 23:14:03 2009 > @@ -34,8 +34,8 @@ > vs->sasl.runSSF =3D vs->sasl.waitWriteSSF =3D vs->sasl.wantSSF = =3D > 0; > vs->sasl.encodedLength =3D vs->sasl.encodedOffset =3D 0; > vs->sasl.encoded =3D NULL; > - free(vs->sasl.username); > - free(vs->sasl.mechlist); > + qemu_free(vs->sasl.username); > + qemu_free(vs->sasl.mechlist); > vs->sasl.username =3D vs->sasl.mechlist =3D NULL; > sasl_dispose(&vs->sasl.conn); > vs->sasl.conn =3D NULL; > @@ -429,7 +429,7 @@ > =20 > static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t > *data,=20 > size_t len) > { > - char *mechname =3D malloc(len + 1); > + char *mechname =3D qemu_malloc(len + 1); > if (!mechname) { > VNC_DEBUG("Out of memory reading mechname\n"); > vnc_client_error(vs); > @@ -462,7 +462,7 @@ > } > } > =20 > - free(vs->sasl.mechlist); > + qemu_free(vs->sasl.mechlist); > vs->sasl.mechlist =3D mechname; > =20 > VNC_DEBUG("Validated mechname '%s'\n", mechname); > @@ -510,7 +510,7 @@ > goto authabort; > =20 > if (!(remoteAddr =3D vnc_socket_remote_addr("%s;%s", vs->csock))) > { > - free(localAddr); > + qemu_free(localAddr); > goto authabort; > } > =20 > @@ -522,8 +522,8 @@ > NULL, /* Callbacks, not needed */ > SASL_SUCCESS_DATA, > &vs->sasl.conn); > - free(localAddr); > - free(remoteAddr); > + qemu_free(localAddr); > + qemu_free(remoteAddr); > localAddr =3D remoteAddr =3D NULL; > =20 > if (err !=3D SASL_OK) { > @@ -612,7 +612,7 @@ > } > VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist); > =20 > - if (!(vs->sasl.mechlist =3D strdup(mechlist))) { > + if (!(vs->sasl.mechlist =3D qemu_strdup(mechlist))) { > VNC_DEBUG("Out of memory"); > sasl_dispose(&vs->sasl.conn); > vs->sasl.conn =3D NULL; > --- qemu.org/vnc-tls.c=09Sat May 16 17:57:27 2009 > +++ qemu/vnc-tls.c=09Thu May 28 23:14:03 2009 > @@ -382,7 +382,7 @@ > vs->tls.session =3D NULL; > } > vs->tls.wiremode =3D VNC_WIREMODE_CLEAR; > - free(vs->tls.dname); > + qemu_free(vs->tls.dname); > } > =20 > =20 > --- qemu.org/vnc.c=09Sat May 16 17:57:27 2009 > +++ qemu/vnc.c=09Thu May 28 23:14:03 2009 > @@ -159,7 +159,7 @@ > =20 > monitor_printf(mon, "Client:\n"); > monitor_printf(mon, "%s", clientAddr); > - free(clientAddr); > + qemu_free(clientAddr); > =20 > #ifdef CONFIG_VNC_TLS > if (client->tls.session && > @@ -190,7 +190,7 @@ > =20 > monitor_printf(mon, "Server:\n"); > monitor_printf(mon, "%s", serverAddr); > - free(serverAddr); > + qemu_free(serverAddr); > monitor_printf(mon, " auth: %s\n",=20 > vnc_auth_name(vnc_display)); > =20 > if (vnc_display->clients) { > @@ -533,8 +533,8 @@ > last_bg, last_fg, &has_bg, > &has_fg); > } > } > - free(last_fg); > - free(last_bg); > + qemu_free(last_fg); > + qemu_free(last_bg); > =20 > } > =20 > @@ -2123,7 +2123,7 @@ > if (strcmp(display, "none") =3D=3D 0) > return 0; > =20 > - if (!(vs->display =3D strdup(display))) > + if (!(vs->display =3D qemu_strdup(display))) > return -1; > =20 > options =3D display; > @@ -2275,7 +2275,7 @@ > if ((saslErr =3D sasl_server_init(NULL, "qemu")) !=3D SASL_OK) { > fprintf(stderr, "Failed to initialize SASL auth %s", > sasl_errstring(saslErr, NULL, NULL)); > - free(vs->display); > + qemu_free(vs->display); > vs->display =3D NULL; > return -1; > } > @@ -2288,7 +2288,7 @@ > else > vs->lsock =3D inet_connect(display, SOCK_STREAM); > if (-1 =3D=3D vs->lsock) { > - free(vs->display); > + qemu_free(vs->display); > vs->display =3D NULL; > return -1; > } else { > @@ -2309,10 +2309,10 @@ > vs->lsock =3D inet_listen(display, dpy, 256, SOCK_STREAM, > 5900); > } > if (-1 =3D=3D vs->lsock) { > - free(dpy); > + qemu_free(dpy); > return -1; > } else { > - free(vs->display); > + qemu_free(vs->display); > vs->display =3D dpy; > } > }