Revision 7267c094

b/acl.c
55 55
    if (acl)
56 56
        return acl;
57 57

  
58
    acl = qemu_malloc(sizeof(*acl));
59
    acl->aclname = qemu_strdup(aclname);
58
    acl = g_malloc(sizeof(*acl));
59
    acl->aclname = g_strdup(aclname);
60 60
    /* Deny by default, so there is no window of "open
61 61
     * access" between QEMU starting, and the user setting
62 62
     * up ACLs in the monitor */
......
65 65
    acl->nentries = 0;
66 66
    QTAILQ_INIT(&acl->entries);
67 67

  
68
    acls = qemu_realloc(acls, sizeof(*acls) * (nacls +1));
68
    acls = g_realloc(acls, sizeof(*acls) * (nacls +1));
69 69
    acls[nacls] = acl;
70 70
    nacls++;
71 71

  
......
116 116
{
117 117
    qemu_acl_entry *entry;
118 118

  
119
    entry = qemu_malloc(sizeof(*entry));
120
    entry->match = qemu_strdup(match);
119
    entry = g_malloc(sizeof(*entry));
120
    entry->match = g_strdup(match);
121 121
    entry->deny = deny;
122 122

  
123 123
    QTAILQ_INSERT_TAIL(&acl->entries, entry, next);
......
142 142
        return qemu_acl_append(acl, deny, match);
143 143

  
144 144

  
145
    entry = qemu_malloc(sizeof(*entry));
146
    entry->match = qemu_strdup(match);
145
    entry = g_malloc(sizeof(*entry));
146
    entry->match = g_strdup(match);
147 147
    entry->deny = deny;
148 148

  
149 149
    QTAILQ_FOREACH(tmp, &acl->entries, next) {
b/aio.c
75 75
                 * releasing the walking_handlers lock.
76 76
                 */
77 77
                QLIST_REMOVE(node, node);
78
                qemu_free(node);
78
                g_free(node);
79 79
            }
80 80
        }
81 81
    } else {
82 82
        if (node == NULL) {
83 83
            /* Alloc and insert if it's not already there */
84
            node = qemu_mallocz(sizeof(AioHandler));
84
            node = g_malloc0(sizeof(AioHandler));
85 85
            node->fd = fd;
86 86
            QLIST_INSERT_HEAD(&aio_handlers, node, node);
87 87
        }
......
220 220

  
221 221
                if (tmp->deleted) {
222 222
                    QLIST_REMOVE(tmp, node);
223
                    qemu_free(tmp);
223
                    g_free(tmp);
224 224
                }
225 225
            }
226 226

  
b/arch_init.c
235 235
    QLIST_FOREACH(block, &ram_list.blocks, next) {
236 236
        ++n;
237 237
    }
238
    blocks = qemu_malloc(n * sizeof *blocks);
238
    blocks = g_malloc(n * sizeof *blocks);
239 239
    n = 0;
240 240
    QLIST_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) {
241 241
        blocks[n++] = block;
......
245 245
    while (--n >= 0) {
246 246
        QLIST_INSERT_HEAD(&ram_list.blocks, blocks[n], next);
247 247
    }
248
    qemu_free(blocks);
248
    g_free(blocks);
249 249
}
250 250

  
251 251
int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
b/async.c
43 43
QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
44 44
{
45 45
    QEMUBH *bh;
46
    bh = qemu_mallocz(sizeof(QEMUBH));
46
    bh = g_malloc0(sizeof(QEMUBH));
47 47
    bh->cb = cb;
48 48
    bh->opaque = opaque;
49 49
    bh->next = first_bh;
......
74 74
        bh = *bhp;
75 75
        if (bh->deleted) {
76 76
            *bhp = bh->next;
77
            qemu_free(bh);
77
            g_free(bh);
78 78
        } else
79 79
            bhp = &bh->next;
80 80
    }
b/audio/alsaaudio.c
136 136
        for (i = 0; i < hlp->count; ++i) {
137 137
            qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
138 138
        }
139
        qemu_free (pfds);
139
        g_free (pfds);
140 140
    }
141 141
    hlp->pfds = NULL;
142 142
    hlp->count = 0;
......
260 260
    if (err < 0) {
261 261
        alsa_logerr (err, "Could not initialize poll mode\n"
262 262
                     "Could not obtain poll descriptors\n");
263
        qemu_free (pfds);
263
        g_free (pfds);
264 264
        return -1;
265 265
    }
266 266

  
......
288 288
            while (i--) {
289 289
                qemu_set_fd_handler (pfds[i].fd, NULL, NULL, NULL);
290 290
            }
291
            qemu_free (pfds);
291
            g_free (pfds);
292 292
            return -1;
293 293
        }
294 294
    }
......
816 816
    alsa_anal_close (&alsa->handle, &alsa->pollhlp);
817 817

  
818 818
    if (alsa->pcm_buf) {
819
        qemu_free (alsa->pcm_buf);
819
        g_free (alsa->pcm_buf);
820 820
        alsa->pcm_buf = NULL;
821 821
    }
822 822
}
......
979 979
    alsa_anal_close (&alsa->handle, &alsa->pollhlp);
980 980

  
981 981
    if (alsa->pcm_buf) {
982
        qemu_free (alsa->pcm_buf);
982
        g_free (alsa->pcm_buf);
983 983
        alsa->pcm_buf = NULL;
984 984
    }
985 985
}
b/audio/audio.c
196 196
        return NULL;
197 197
    }
198 198

  
199
    return qemu_mallocz (len);
199
    return g_malloc0 (len);
200 200
}
201 201

  
202 202
static char *audio_alloc_prefix (const char *s)
......
210 210
    }
211 211

  
212 212
    len = strlen (s);
213
    r = qemu_malloc (len + sizeof (qemu_prefix));
213
    r = g_malloc (len + sizeof (qemu_prefix));
214 214

  
215 215
    u = r + sizeof (qemu_prefix) - 1;
216 216

  
......
425 425
        printf ("    %s\n", opt->descr);
426 426
    }
427 427

  
428
    qemu_free (uprefix);
428
    g_free (uprefix);
429 429
}
430 430

  
431 431
static void audio_process_options (const char *prefix,
......
462 462
         * (includes trailing zero) + zero + underscore (on behalf of
463 463
         * sizeof) */
464 464
        optlen = len + preflen + sizeof (qemu_prefix) + 1;
465
        optname = qemu_malloc (optlen);
465
        optname = g_malloc (optlen);
466 466

  
467 467
        pstrcpy (optname, optlen, qemu_prefix);
468 468

  
......
507 507
            opt->overriddenp = &opt->overridden;
508 508
        }
509 509
        *opt->overriddenp = !def;
510
        qemu_free (optname);
510
        g_free (optname);
511 511
    }
512 512
}
513 513

  
......
778 778

  
779 779
        QLIST_REMOVE (sw, entries);
780 780
        QLIST_REMOVE (sc, entries);
781
        qemu_free (sc);
781
        g_free (sc);
782 782
        if (was_active) {
783 783
            /* We have removed soft voice from the capture:
784 784
               this might have changed the overall status of the capture
......
818 818
        sw->rate = st_rate_start (sw->info.freq, hw_cap->info.freq);
819 819
        if (!sw->rate) {
820 820
            dolog ("Could not start rate conversion for `%s'\n", SW_NAME (sw));
821
            qemu_free (sw);
821
            g_free (sw);
822 822
            return -1;
823 823
        }
824 824
        QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
......
1907 1907
void AUD_register_card (const char *name, QEMUSoundCard *card)
1908 1908
{
1909 1909
    audio_init ();
1910
    card->name = qemu_strdup (name);
1910
    card->name = g_strdup (name);
1911 1911
    memset (&card->entries, 0, sizeof (card->entries));
1912 1912
    QLIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries);
1913 1913
}
......
1915 1915
void AUD_remove_card (QEMUSoundCard *card)
1916 1916
{
1917 1917
    QLIST_REMOVE (card, entries);
1918
    qemu_free (card->name);
1918
    g_free (card->name);
1919 1919
}
1920 1920

  
1921 1921

  
......
2000 2000
        return cap;
2001 2001

  
2002 2002
    err3:
2003
        qemu_free (cap->hw.mix_buf);
2003
        g_free (cap->hw.mix_buf);
2004 2004
    err2:
2005
        qemu_free (cap);
2005
        g_free (cap);
2006 2006
    err1:
2007
        qemu_free (cb);
2007
        g_free (cb);
2008 2008
    err0:
2009 2009
        return NULL;
2010 2010
    }
......
2018 2018
        if (cb->opaque == cb_opaque) {
2019 2019
            cb->ops.destroy (cb_opaque);
2020 2020
            QLIST_REMOVE (cb, entries);
2021
            qemu_free (cb);
2021
            g_free (cb);
2022 2022

  
2023 2023
            if (!cap->cb_head.lh_first) {
2024 2024
                SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
......
2036 2036
                    }
2037 2037
                    QLIST_REMOVE (sw, entries);
2038 2038
                    QLIST_REMOVE (sc, entries);
2039
                    qemu_free (sc);
2039
                    g_free (sc);
2040 2040
                    sw = sw1;
2041 2041
                }
2042 2042
                QLIST_REMOVE (cap, entries);
2043
                qemu_free (cap);
2043
                g_free (cap);
2044 2044
            }
2045 2045
            return;
2046 2046
        }
b/audio/audio_template.h
72 72
static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)
73 73
{
74 74
    if (HWBUF) {
75
        qemu_free (HWBUF);
75
        g_free (HWBUF);
76 76
    }
77 77

  
78 78
    HWBUF = NULL;
......
93 93
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
94 94
{
95 95
    if (sw->buf) {
96
        qemu_free (sw->buf);
96
        g_free (sw->buf);
97 97
    }
98 98

  
99 99
    if (sw->rate) {
......
123 123
    sw->rate = st_rate_start (sw->hw->info.freq, sw->info.freq);
124 124
#endif
125 125
    if (!sw->rate) {
126
        qemu_free (sw->buf);
126
        g_free (sw->buf);
127 127
        sw->buf = NULL;
128 128
        return -1;
129 129
    }
......
160 160
        [sw->info.swap_endianness]
161 161
        [audio_bits_to_index (sw->info.bits)];
162 162

  
163
    sw->name = qemu_strdup (name);
163
    sw->name = g_strdup (name);
164 164
    err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
165 165
    if (err) {
166
        qemu_free (sw->name);
166
        g_free (sw->name);
167 167
        sw->name = NULL;
168 168
    }
169 169
    return err;
......
173 173
{
174 174
    glue (audio_pcm_sw_free_resources_, TYPE) (sw);
175 175
    if (sw->name) {
176
        qemu_free (sw->name);
176
        g_free (sw->name);
177 177
        sw->name = NULL;
178 178
    }
179 179
}
......
201 201
        glue (s->nb_hw_voices_, TYPE) += 1;
202 202
        glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
203 203
        glue (hw->pcm_ops->fini_, TYPE) (hw);
204
        qemu_free (hw);
204
        g_free (hw);
205 205
        *hwp = NULL;
206 206
    }
207 207
}
......
300 300
 err1:
301 301
    glue (hw->pcm_ops->fini_, TYPE) (hw);
302 302
 err0:
303
    qemu_free (hw);
303
    g_free (hw);
304 304
    return NULL;
305 305
}
306 306

  
......
368 368
    glue (audio_pcm_hw_del_sw_, TYPE) (sw);
369 369
    glue (audio_pcm_hw_gc_, TYPE) (&hw);
370 370
err2:
371
    qemu_free (sw);
371
    g_free (sw);
372 372
err1:
373 373
    return NULL;
374 374
}
......
378 378
    glue (audio_pcm_sw_fini_, TYPE) (sw);
379 379
    glue (audio_pcm_hw_del_sw_, TYPE) (sw);
380 380
    glue (audio_pcm_hw_gc_, TYPE) (&sw->hw);
381
    qemu_free (sw);
381
    g_free (sw);
382 382
}
383 383

  
384 384
void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw)
b/audio/esdaudio.c
246 246
    esd->fd = -1;
247 247

  
248 248
 fail1:
249
    qemu_free (esd->pcm_buf);
249
    g_free (esd->pcm_buf);
250 250
    esd->pcm_buf = NULL;
251 251
    return -1;
252 252
}
......
270 270

  
271 271
    audio_pt_fini (&esd->pt, AUDIO_FUNC);
272 272

  
273
    qemu_free (esd->pcm_buf);
273
    g_free (esd->pcm_buf);
274 274
    esd->pcm_buf = NULL;
275 275
}
276 276

  
......
453 453
    esd->fd = -1;
454 454

  
455 455
 fail1:
456
    qemu_free (esd->pcm_buf);
456
    g_free (esd->pcm_buf);
457 457
    esd->pcm_buf = NULL;
458 458
    return -1;
459 459
}
......
477 477

  
478 478
    audio_pt_fini (&esd->pt, AUDIO_FUNC);
479 479

  
480
    qemu_free (esd->pcm_buf);
480
    g_free (esd->pcm_buf);
481 481
    esd->pcm_buf = NULL;
482 482
}
483 483

  
b/audio/mixeng.c
326 326

  
327 327
void st_rate_stop (void *opaque)
328 328
{
329
    qemu_free (opaque);
329
    g_free (opaque);
330 330
}
331 331

  
332 332
void mixeng_clear (struct st_sample *buf, int len)
b/audio/ossaudio.c
508 508
            }
509 509
        }
510 510
        else {
511
            qemu_free (oss->pcm_buf);
511
            g_free (oss->pcm_buf);
512 512
        }
513 513
        oss->pcm_buf = NULL;
514 514
    }
......
741 741
    oss_anal_close (&oss->fd);
742 742

  
743 743
    if (oss->pcm_buf) {
744
        qemu_free (oss->pcm_buf);
744
        g_free (oss->pcm_buf);
745 745
        oss->pcm_buf = NULL;
746 746
    }
747 747
}
b/audio/paaudio.c
339 339
    return 0;
340 340

  
341 341
 fail3:
342
    qemu_free (pa->pcm_buf);
342
    g_free (pa->pcm_buf);
343 343
    pa->pcm_buf = NULL;
344 344
 fail2:
345 345
    pa_simple_free (pa->s);
......
394 394
    return 0;
395 395

  
396 396
 fail3:
397
    qemu_free (pa->pcm_buf);
397
    g_free (pa->pcm_buf);
398 398
    pa->pcm_buf = NULL;
399 399
 fail2:
400 400
    pa_simple_free (pa->s);
......
419 419
    }
420 420

  
421 421
    audio_pt_fini (&pa->pt, AUDIO_FUNC);
422
    qemu_free (pa->pcm_buf);
422
    g_free (pa->pcm_buf);
423 423
    pa->pcm_buf = NULL;
424 424
}
425 425

  
......
439 439
    }
440 440

  
441 441
    audio_pt_fini (&pa->pt, AUDIO_FUNC);
442
    qemu_free (pa->pcm_buf);
442
    g_free (pa->pcm_buf);
443 443
    pa->pcm_buf = NULL;
444 444
}
445 445

  
b/audio/wavaudio.c
156 156
    if (!wav->f) {
157 157
        dolog ("Failed to open wave file `%s'\nReason: %s\n",
158 158
               conf.wav_path, strerror (errno));
159
        qemu_free (wav->pcm_buf);
159
        g_free (wav->pcm_buf);
160 160
        wav->pcm_buf = NULL;
161 161
        return -1;
162 162
    }
......
189 189
    qemu_fclose (wav->f);
190 190
    wav->f = NULL;
191 191

  
192
    qemu_free (wav->pcm_buf);
192
    g_free (wav->pcm_buf);
193 193
    wav->pcm_buf = NULL;
194 194
}
195 195

  
b/audio/wavcapture.c
48 48
        qemu_fclose (wav->f);
49 49
    }
50 50

  
51
    qemu_free (wav->path);
51
    g_free (wav->path);
52 52
}
53 53

  
54 54
static void wav_capture (void *opaque, void *buf, int size)
......
120 120
    ops.capture = wav_capture;
121 121
    ops.destroy = wav_destroy;
122 122

  
123
    wav = qemu_mallocz (sizeof (*wav));
123
    wav = g_malloc0 (sizeof (*wav));
124 124

  
125 125
    shift = bits16 + stereo;
126 126
    hdr[34] = bits16 ? 0x10 : 0x08;
......
134 134
    if (!wav->f) {
135 135
        monitor_printf(mon, "Failed to open wave file `%s'\nReason: %s\n",
136 136
                       path, strerror (errno));
137
        qemu_free (wav);
137
        g_free (wav);
138 138
        return -1;
139 139
    }
140 140

  
141
    wav->path = qemu_strdup (path);
141
    wav->path = g_strdup (path);
142 142
    wav->bits = bits;
143 143
    wav->nchannels = nchannels;
144 144
    wav->freq = freq;
......
148 148
    cap = AUD_add_capture (&as, &ops, wav);
149 149
    if (!cap) {
150 150
        monitor_printf(mon, "Failed to add audio capture\n");
151
        qemu_free (wav->path);
151
        g_free (wav->path);
152 152
        qemu_fclose (wav->f);
153
        qemu_free (wav);
153
        g_free (wav);
154 154
        return -1;
155 155
    }
156 156

  
b/audio/winwaveaudio.c
222 222
    return 0;
223 223

  
224 224
 err4:
225
    qemu_free (wave->pcm_buf);
225
    g_free (wave->pcm_buf);
226 226
 err3:
227
    qemu_free (wave->hdrs);
227
    g_free (wave->hdrs);
228 228
 err2:
229 229
    winwave_anal_close_out (wave);
230 230
 err1:
......
310 310
        wave->event = NULL;
311 311
    }
312 312

  
313
    qemu_free (wave->pcm_buf);
313
    g_free (wave->pcm_buf);
314 314
    wave->pcm_buf = NULL;
315 315

  
316
    qemu_free (wave->hdrs);
316
    g_free (wave->hdrs);
317 317
    wave->hdrs = NULL;
318 318
}
319 319

  
......
511 511
    return 0;
512 512

  
513 513
 err4:
514
    qemu_free (wave->pcm_buf);
514
    g_free (wave->pcm_buf);
515 515
 err3:
516
    qemu_free (wave->hdrs);
516
    g_free (wave->hdrs);
517 517
 err2:
518 518
    winwave_anal_close_in (wave);
519 519
 err1:
......
550 550
        wave->event = NULL;
551 551
    }
552 552

  
553
    qemu_free (wave->pcm_buf);
553
    g_free (wave->pcm_buf);
554 554
    wave->pcm_buf = NULL;
555 555

  
556
    qemu_free (wave->hdrs);
556
    g_free (wave->hdrs);
557 557
    wave->hdrs = NULL;
558 558
}
559 559

  
b/bitmap.h
91 91
static inline unsigned long *bitmap_new(int nbits)
92 92
{
93 93
    int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long);
94
    return qemu_mallocz(len);
94
    return g_malloc0(len);
95 95
}
96 96

  
97 97
static inline void bitmap_zero(unsigned long *dst, int nbits)
b/block-migration.c
180 180
            BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
181 181
    bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
182 182

  
183
    bmds->aio_bitmap = qemu_mallocz(bitmap_size);
183
    bmds->aio_bitmap = g_malloc0(bitmap_size);
184 184
}
185 185

  
186 186
static void blk_mig_read_cb(void *opaque, int ret)
......
235 235
        nr_sectors = total_sectors - cur_sector;
236 236
    }
237 237

  
238
    blk = qemu_malloc(sizeof(BlkMigBlock));
239
    blk->buf = qemu_malloc(BLOCK_SIZE);
238
    blk = g_malloc(sizeof(BlkMigBlock));
239
    blk->buf = g_malloc(BLOCK_SIZE);
240 240
    blk->bmds = bmds;
241 241
    blk->sector = cur_sector;
242 242
    blk->nr_sectors = nr_sectors;
......
264 264
error:
265 265
    monitor_printf(mon, "Error reading sector %" PRId64 "\n", cur_sector);
266 266
    qemu_file_set_error(f);
267
    qemu_free(blk->buf);
268
    qemu_free(blk);
267
    g_free(blk->buf);
268
    g_free(blk);
269 269
    return 0;
270 270
}
271 271

  
......
290 290
            return;
291 291
        }
292 292

  
293
        bmds = qemu_mallocz(sizeof(BlkMigDevState));
293
        bmds = g_malloc0(sizeof(BlkMigDevState));
294 294
        bmds->bs = bs;
295 295
        bmds->bulk_completed = 0;
296 296
        bmds->total_sectors = sectors;
......
395 395
            } else {
396 396
                nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
397 397
            }
398
            blk = qemu_malloc(sizeof(BlkMigBlock));
399
            blk->buf = qemu_malloc(BLOCK_SIZE);
398
            blk = g_malloc(sizeof(BlkMigBlock));
399
            blk->buf = g_malloc(BLOCK_SIZE);
400 400
            blk->bmds = bmds;
401 401
            blk->sector = sector;
402 402
            blk->nr_sectors = nr_sectors;
......
424 424
                }
425 425
                blk_send(f, blk);
426 426

  
427
                qemu_free(blk->buf);
428
                qemu_free(blk);
427
                g_free(blk->buf);
428
                g_free(blk);
429 429
            }
430 430

  
431 431
            bdrv_reset_dirty(bmds->bs, sector, nr_sectors);
......
440 440
error:
441 441
    monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector);
442 442
    qemu_file_set_error(f);
443
    qemu_free(blk->buf);
444
    qemu_free(blk);
443
    g_free(blk->buf);
444
    g_free(blk);
445 445
    return 0;
446 446
}
447 447

  
......
479 479
        blk_send(f, blk);
480 480

  
481 481
        QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
482
        qemu_free(blk->buf);
483
        qemu_free(blk);
482
        g_free(blk->buf);
483
        g_free(blk);
484 484

  
485 485
        block_mig_state.read_done--;
486 486
        block_mig_state.transferred++;
......
541 541
        QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
542 542
        bdrv_set_in_use(bmds->bs, 0);
543 543
        drive_put_ref(drive_get_by_blockdev(bmds->bs));
544
        qemu_free(bmds->aio_bitmap);
545
        qemu_free(bmds);
544
        g_free(bmds->aio_bitmap);
545
        g_free(bmds);
546 546
    }
547 547

  
548 548
    while ((blk = QSIMPLEQ_FIRST(&block_mig_state.blk_list)) != NULL) {
549 549
        QSIMPLEQ_REMOVE_HEAD(&block_mig_state.blk_list, entry);
550
        qemu_free(blk->buf);
551
        qemu_free(blk);
550
        g_free(blk->buf);
551
        g_free(blk);
552 552
    }
553 553

  
554 554
    monitor_printf(mon, "\n");
......
683 683
                nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK;
684 684
            }
685 685

  
686
            buf = qemu_malloc(BLOCK_SIZE);
686
            buf = g_malloc(BLOCK_SIZE);
687 687

  
688 688
            qemu_get_buffer(f, buf, BLOCK_SIZE);
689 689
            ret = bdrv_write(bs, addr, buf, nr_sectors);
690 690

  
691
            qemu_free(buf);
691
            g_free(buf);
692 692
            if (ret < 0) {
693 693
                return ret;
694 694
            }
b/block.c
215 215
{
216 216
    BlockDriverState *bs;
217 217

  
218
    bs = qemu_mallocz(sizeof(BlockDriverState));
218
    bs = g_malloc0(sizeof(BlockDriverState));
219 219
    pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
220 220
    if (device_name[0] != '\0') {
221 221
        QTAILQ_INSERT_TAIL(&bdrv_states, bs, list);
......
462 462
    }
463 463

  
464 464
    bs->drv = drv;
465
    bs->opaque = qemu_mallocz(drv->instance_size);
465
    bs->opaque = g_malloc0(drv->instance_size);
466 466

  
467 467
    if (flags & BDRV_O_CACHE_WB)
468 468
        bs->enable_write_cache = 1;
......
513 513
        bdrv_delete(bs->file);
514 514
        bs->file = NULL;
515 515
    }
516
    qemu_free(bs->opaque);
516
    g_free(bs->opaque);
517 517
    bs->opaque = NULL;
518 518
    bs->drv = NULL;
519 519
    return ret;
......
687 687
            bs->backing_hd = NULL;
688 688
        }
689 689
        bs->drv->bdrv_close(bs);
690
        qemu_free(bs->opaque);
690
        g_free(bs->opaque);
691 691
#ifdef _WIN32
692 692
        if (bs->is_temporary) {
693 693
            unlink(bs->filename);
......
739 739
    }
740 740

  
741 741
    assert(bs != bs_snapshots);
742
    qemu_free(bs);
742
    g_free(bs);
743 743
}
744 744

  
745 745
int bdrv_attach(BlockDriverState *bs, DeviceState *qdev)
......
837 837
    }
838 838

  
839 839
    total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
840
    buf = qemu_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
840
    buf = g_malloc(COMMIT_BUF_SECTORS * BDRV_SECTOR_SIZE);
841 841

  
842 842
    for (sector = 0; sector < total_sectors; sector += n) {
843 843
        if (drv->bdrv_is_allocated(bs, sector, COMMIT_BUF_SECTORS, &n)) {
......
867 867
        bdrv_flush(bs->backing_hd);
868 868

  
869 869
ro_cleanup:
870
    qemu_free(buf);
870
    g_free(buf);
871 871

  
872 872
    if (ro) {
873 873
        /* re-open as RO */
......
2275 2275
        set_dirty_bitmap(b->bs, b->sector_num, b->nb_sectors, 1);
2276 2276
    }
2277 2277
    b->cb(b->opaque, ret);
2278
    qemu_free(b);
2278
    g_free(b);
2279 2279
}
2280 2280

  
2281 2281
static BlockCompleteData *blk_dirty_cb_alloc(BlockDriverState *bs,
......
2284 2284
                                             BlockDriverCompletionFunc *cb,
2285 2285
                                             void *opaque)
2286 2286
{
2287
    BlockCompleteData *blkdata = qemu_mallocz(sizeof(BlockCompleteData));
2287
    BlockCompleteData *blkdata = g_malloc0(sizeof(BlockCompleteData));
2288 2288

  
2289 2289
    blkdata->bs = bs;
2290 2290
    blkdata->cb = cb;
......
2356 2356
        if (mcb->callbacks[i].free_qiov) {
2357 2357
            qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
2358 2358
        }
2359
        qemu_free(mcb->callbacks[i].free_qiov);
2359
        g_free(mcb->callbacks[i].free_qiov);
2360 2360
        qemu_vfree(mcb->callbacks[i].free_buf);
2361 2361
    }
2362 2362
}
......
2374 2374
    mcb->num_requests--;
2375 2375
    if (mcb->num_requests == 0) {
2376 2376
        multiwrite_user_cb(mcb);
2377
        qemu_free(mcb);
2377
        g_free(mcb);
2378 2378
    }
2379 2379
}
2380 2380

  
......
2434 2434

  
2435 2435
        if (merge) {
2436 2436
            size_t size;
2437
            QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
2437
            QEMUIOVector *qiov = g_malloc0(sizeof(*qiov));
2438 2438
            qemu_iovec_init(qiov,
2439 2439
                reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1);
2440 2440

  
......
2503 2503
    }
2504 2504

  
2505 2505
    // Create MultiwriteCB structure
2506
    mcb = qemu_mallocz(sizeof(*mcb) + num_reqs * sizeof(*mcb->callbacks));
2506
    mcb = g_malloc0(sizeof(*mcb) + num_reqs * sizeof(*mcb->callbacks));
2507 2507
    mcb->num_requests = 0;
2508 2508
    mcb->num_callbacks = num_reqs;
2509 2509

  
......
2568 2568
    for (i = 0; i < mcb->num_callbacks; i++) {
2569 2569
        reqs[i].error = -EIO;
2570 2570
    }
2571
    qemu_free(mcb);
2571
    g_free(mcb);
2572 2572
    return -1;
2573 2573
}
2574 2574

  
......
2884 2884
        acb = pool->free_aiocb;
2885 2885
        pool->free_aiocb = acb->next;
2886 2886
    } else {
2887
        acb = qemu_mallocz(pool->aiocb_size);
2887
        acb = g_malloc0(pool->aiocb_size);
2888 2888
        acb->pool = pool;
2889 2889
    }
2890 2890
    acb->bs = bs;
......
3088 3088
                    BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
3089 3089
            bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
3090 3090

  
3091
            bs->dirty_bitmap = qemu_mallocz(bitmap_size);
3091
            bs->dirty_bitmap = g_malloc0(bitmap_size);
3092 3092
        }
3093 3093
    } else {
3094 3094
        if (bs->dirty_bitmap) {
3095
            qemu_free(bs->dirty_bitmap);
3095
            g_free(bs->dirty_bitmap);
3096 3096
            bs->dirty_bitmap = NULL;
3097 3097
        }
3098 3098
    }
b/block/blkdebug.c
214 214
    }
215 215

  
216 216
    /* Set attributes common for all actions */
217
    rule = qemu_mallocz(sizeof(*rule));
217
    rule = g_malloc0(sizeof(*rule));
218 218
    *rule = (struct BlkdebugRule) {
219 219
        .event  = event,
220 220
        .action = d->action,
......
392 392
    for (i = 0; i < BLKDBG_EVENT_MAX; i++) {
393 393
        QLIST_FOREACH_SAFE(rule, &s->rules[i], next, next) {
394 394
            QLIST_REMOVE(rule, next);
395
            qemu_free(rule);
395
            g_free(rule);
396 396
        }
397 397
    }
398 398
}
b/block/bochs.c
136 136
    }
137 137

  
138 138
    s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
139
    s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
139
    s->catalog_bitmap = g_malloc(s->catalog_size * 4);
140 140
    if (bdrv_pread(bs->file, le32_to_cpu(bochs.header), s->catalog_bitmap,
141 141
                   s->catalog_size * 4) != s->catalog_size * 4)
142 142
	goto fail;
......
210 210
static void bochs_close(BlockDriverState *bs)
211 211
{
212 212
    BDRVBochsState *s = bs->opaque;
213
    qemu_free(s->catalog_bitmap);
213
    g_free(s->catalog_bitmap);
214 214
}
215 215

  
216 216
static BlockDriver bdrv_bochs = {
b/block/cloop.c
70 70

  
71 71
    /* read offsets */
72 72
    offsets_size = s->n_blocks * sizeof(uint64_t);
73
    s->offsets = qemu_malloc(offsets_size);
73
    s->offsets = g_malloc(offsets_size);
74 74
    if (bdrv_pread(bs->file, 128 + 4 + 4, s->offsets, offsets_size) <
75 75
            offsets_size) {
76 76
	goto cloop_close;
......
85 85
    }
86 86

  
87 87
    /* initialize zlib engine */
88
    s->compressed_block = qemu_malloc(max_compressed_block_size+1);
89
    s->uncompressed_block = qemu_malloc(s->block_size);
88
    s->compressed_block = g_malloc(max_compressed_block_size+1);
89
    s->uncompressed_block = g_malloc(s->block_size);
90 90
    if(inflateInit(&s->zstream) != Z_OK)
91 91
	goto cloop_close;
92 92
    s->current_block=s->n_blocks;
b/block/curl.c
310 310

  
311 311
    static int inited = 0;
312 312

  
313
    file = qemu_strdup(filename);
313
    file = g_strdup(filename);
314 314
    s->readahead_size = READ_AHEAD_SIZE;
315 315

  
316 316
    /* Parse a trailing ":readahead=#:" param, if present. */
......
390 390
    curl_easy_cleanup(state->curl);
391 391
    state->curl = NULL;
392 392
out_noclean:
393
    qemu_free(file);
393
    g_free(file);
394 394
    return -EINVAL;
395 395
}
396 396

  
......
444 444

  
445 445
    state->buf_off = 0;
446 446
    if (state->orig_buf)
447
        qemu_free(state->orig_buf);
447
        g_free(state->orig_buf);
448 448
    state->buf_start = start;
449 449
    state->buf_len = acb->end + s->readahead_size;
450 450
    end = MIN(start + state->buf_len, s->len) - 1;
451
    state->orig_buf = qemu_malloc(state->buf_len);
451
    state->orig_buf = g_malloc(state->buf_len);
452 452
    state->acb[0] = acb;
453 453

  
454 454
    snprintf(state->range, 127, "%zd-%zd", start, end);
......
476 476
            s->states[i].curl = NULL;
477 477
        }
478 478
        if (s->states[i].orig_buf) {
479
            qemu_free(s->states[i].orig_buf);
479
            g_free(s->states[i].orig_buf);
480 480
            s->states[i].orig_buf = NULL;
481 481
        }
482 482
    }
b/block/dmg.c
127 127

  
128 128
	    chunk_count = (count-204)/40;
129 129
	    new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
130
	    s->types = qemu_realloc(s->types, new_size/2);
131
	    s->offsets = qemu_realloc(s->offsets, new_size);
132
	    s->lengths = qemu_realloc(s->lengths, new_size);
133
	    s->sectors = qemu_realloc(s->sectors, new_size);
134
	    s->sectorcounts = qemu_realloc(s->sectorcounts, new_size);
130
	    s->types = g_realloc(s->types, new_size/2);
131
	    s->offsets = g_realloc(s->offsets, new_size);
132
	    s->lengths = g_realloc(s->lengths, new_size);
133
	    s->sectors = g_realloc(s->sectors, new_size);
134
	    s->sectorcounts = g_realloc(s->sectorcounts, new_size);
135 135

  
136 136
	    for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
137 137
		s->types[i] = read_uint32(bs, offset);
......
170 170
    }
171 171

  
172 172
    /* initialize zlib engine */
173
    s->compressed_chunk = qemu_malloc(max_compressed_size+1);
174
    s->uncompressed_chunk = qemu_malloc(512*max_sectors_per_chunk);
173
    s->compressed_chunk = g_malloc(max_compressed_size+1);
174
    s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk);
175 175
    if(inflateInit(&s->zstream) != Z_OK)
176 176
	goto fail;
177 177

  
b/block/nbd.c
65 65
    const char *unixpath;
66 66
    int err = -EINVAL;
67 67

  
68
    file = qemu_strdup(filename);
68
    file = g_strdup(filename);
69 69

  
70 70
    export_name = strstr(file, EN_OPTSTR);
71 71
    if (export_name) {
......
74 74
        }
75 75
        export_name[0] = 0; /* truncate 'file' */
76 76
        export_name += strlen(EN_OPTSTR);
77
        s->export_name = qemu_strdup(export_name);
77
        s->export_name = g_strdup(export_name);
78 78
    }
79 79

  
80 80
    /* extract the host_spec - fail if it's not nbd:... */
......
87 87
        if (unixpath[0] != '/') { /* We demand  an absolute path*/
88 88
            goto out;
89 89
        }
90
        s->host_spec = qemu_strdup(unixpath);
90
        s->host_spec = g_strdup(unixpath);
91 91
    } else {
92
        s->host_spec = qemu_strdup(host_spec);
92
        s->host_spec = g_strdup(host_spec);
93 93
    }
94 94

  
95 95
    err = 0;
96 96

  
97 97
out:
98
    qemu_free(file);
98
    g_free(file);
99 99
    if (err != 0) {
100
        qemu_free(s->export_name);
101
        qemu_free(s->host_spec);
100
        g_free(s->export_name);
101
        g_free(s->host_spec);
102 102
    }
103 103
    return err;
104 104
}
......
240 240
static void nbd_close(BlockDriverState *bs)
241 241
{
242 242
    BDRVNBDState *s = bs->opaque;
243
    qemu_free(s->export_name);
244
    qemu_free(s->host_spec);
243
    g_free(s->export_name);
244
    g_free(s->host_spec);
245 245

  
246 246
    nbd_teardown_connection(bs);
247 247
}
b/block/parallels.c
88 88
    s->tracks = le32_to_cpu(ph.tracks);
89 89

  
90 90
    s->catalog_size = le32_to_cpu(ph.catalog_entries);
91
    s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
91
    s->catalog_bitmap = g_malloc(s->catalog_size * 4);
92 92
    if (bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4) !=
93 93
	s->catalog_size * 4)
94 94
	goto fail;
......
98 98
    return 0;
99 99
fail:
100 100
    if (s->catalog_bitmap)
101
	qemu_free(s->catalog_bitmap);
101
	g_free(s->catalog_bitmap);
102 102
    return -1;
103 103
}
104 104

  
......
137 137
static void parallels_close(BlockDriverState *bs)
138 138
{
139 139
    BDRVParallelsState *s = bs->opaque;
140
    qemu_free(s->catalog_bitmap);
140
    g_free(s->catalog_bitmap);
141 141
}
142 142

  
143 143
static BlockDriver bdrv_parallels = {
b/block/qcow.c
129 129
    s->l1_size = (header.size + (1LL << shift) - 1) >> shift;
130 130

  
131 131
    s->l1_table_offset = header.l1_table_offset;
132
    s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
132
    s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t));
133 133
    if (!s->l1_table)
134 134
        goto fail;
135 135
    if (bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
......
139 139
        be64_to_cpus(&s->l1_table[i]);
140 140
    }
141 141
    /* alloc L2 cache */
142
    s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
142
    s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
143 143
    if (!s->l2_cache)
144 144
        goto fail;
145
    s->cluster_cache = qemu_malloc(s->cluster_size);
145
    s->cluster_cache = g_malloc(s->cluster_size);
146 146
    if (!s->cluster_cache)
147 147
        goto fail;
148
    s->cluster_data = qemu_malloc(s->cluster_size);
148
    s->cluster_data = g_malloc(s->cluster_size);
149 149
    if (!s->cluster_data)
150 150
        goto fail;
151 151
    s->cluster_cache_offset = -1;
......
162 162
    return 0;
163 163

  
164 164
 fail:
165
    qemu_free(s->l1_table);
166
    qemu_free(s->l2_cache);
167
    qemu_free(s->cluster_cache);
168
    qemu_free(s->cluster_data);
165
    g_free(s->l1_table);
166
    g_free(s->l2_cache);
167
    g_free(s->cluster_cache);
168
    g_free(s->cluster_data);
169 169
    return -1;
170 170
}
171 171

  
......
687 687
    }
688 688
    if (s->crypt_method) {
689 689
        if (!acb->cluster_data) {
690
            acb->cluster_data = qemu_mallocz(s->cluster_size);
690
            acb->cluster_data = g_malloc0(s->cluster_size);
691 691
        }
692 692
        encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
693 693
                        acb->n, 1, &s->aes_encrypt_key);
......
738 738
static void qcow_close(BlockDriverState *bs)
739 739
{
740 740
    BDRVQcowState *s = bs->opaque;
741
    qemu_free(s->l1_table);
742
    qemu_free(s->l2_cache);
743
    qemu_free(s->cluster_cache);
744
    qemu_free(s->cluster_data);
741
    g_free(s->l1_table);
742
    g_free(s->l2_cache);
743
    g_free(s->cluster_cache);
744
    g_free(s->cluster_data);
745 745
}
746 746

  
747 747
static int qcow_create(const char *filename, QEMUOptionParameter *options)
......
869 869
    if (nb_sectors != s->cluster_sectors)
870 870
        return -EINVAL;
871 871

  
872
    out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
872
    out_buf = g_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
873 873
    if (!out_buf)
874 874
        return -1;
875 875

  
......
879 879
                       Z_DEFLATED, -12,
880 880
                       9, Z_DEFAULT_STRATEGY);
881 881
    if (ret != 0) {
882
        qemu_free(out_buf);
882
        g_free(out_buf);
883 883
        return -1;
884 884
    }
885 885

  
......
890 890

  
891 891
    ret = deflate(&strm, Z_FINISH);
892 892
    if (ret != Z_STREAM_END && ret != Z_OK) {
893
        qemu_free(out_buf);
893
        g_free(out_buf);
894 894
        deflateEnd(&strm);
895 895
        return -1;
896 896
    }
......
906 906
                                            out_len, 0, 0);
907 907
        cluster_offset &= s->cluster_offset_mask;
908 908
        if (bdrv_pwrite(bs->file, cluster_offset, out_buf, out_len) != out_len) {
909
            qemu_free(out_buf);
909
            g_free(out_buf);
910 910
            return -1;
911 911
        }
912 912
    }
913 913

  
914
    qemu_free(out_buf);
914
    g_free(out_buf);
915 915
    return 0;
916 916
}
917 917

  
b/block/qcow2-cache.c
49 49
    Qcow2Cache *c;
50 50
    int i;
51 51

  
52
    c = qemu_mallocz(sizeof(*c));
52
    c = g_malloc0(sizeof(*c));
53 53
    c->size = num_tables;
54
    c->entries = qemu_mallocz(sizeof(*c->entries) * num_tables);
54
    c->entries = g_malloc0(sizeof(*c->entries) * num_tables);
55 55
    c->writethrough = writethrough;
56 56

  
57 57
    for (i = 0; i < c->size; i++) {
......
70 70
        qemu_vfree(c->entries[i].table);
71 71
    }
72 72

  
73
    qemu_free(c->entries);
74
    qemu_free(c);
73
    g_free(c->entries);
74
    g_free(c);
75 75

  
76 76
    return 0;
77 77
}
b/block/qcow2-cluster.c
57 57
#endif
58 58

  
59 59
    new_l1_size2 = sizeof(uint64_t) * new_l1_size;
60
    new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512));
60
    new_l1_table = g_malloc0(align_offset(new_l1_size2, 512));
61 61
    memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
62 62

  
63 63
    /* write new table (align to cluster) */
64 64
    BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_ALLOC_TABLE);
65 65
    new_l1_table_offset = qcow2_alloc_clusters(bs, new_l1_size2);
66 66
    if (new_l1_table_offset < 0) {
67
        qemu_free(new_l1_table);
67
        g_free(new_l1_table);
68 68
        return new_l1_table_offset;
69 69
    }
70 70

  
......
90 90
    if (ret < 0) {
91 91
        goto fail;
92 92
    }
93
    qemu_free(s->l1_table);
93
    g_free(s->l1_table);
94 94
    qcow2_free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
95 95
    s->l1_table_offset = new_l1_table_offset;
96 96
    s->l1_table = new_l1_table;
97 97
    s->l1_size = new_l1_size;
98 98
    return 0;
99 99
 fail:
100
    qemu_free(new_l1_table);
100
    g_free(new_l1_table);
101 101
    qcow2_free_clusters(bs, new_l1_table_offset, new_l1_size2);
102 102
    return ret;
103 103
}
......
612 612
    if (m->nb_clusters == 0)
613 613
        return 0;
614 614

  
615
    old_cluster = qemu_malloc(m->nb_clusters * sizeof(uint64_t));
615
    old_cluster = g_malloc(m->nb_clusters * sizeof(uint64_t));
616 616

  
617 617
    /* copy content of unmodified sectors */
618 618
    start_sect = (m->offset & ~(s->cluster_size - 1)) >> 9;
......
683 683

  
684 684
    ret = 0;
685 685
err:
686
    qemu_free(old_cluster);
686
    g_free(old_cluster);
687 687
    return ret;
688 688
 }
689 689

  
b/block/qcow2-refcount.c
41 41
    int ret, refcount_table_size2, i;
42 42

  
43 43
    refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t);
44
    s->refcount_table = qemu_malloc(refcount_table_size2);
44
    s->refcount_table = g_malloc(refcount_table_size2);
45 45
    if (s->refcount_table_size > 0) {
46 46
        BLKDBG_EVENT(bs->file, BLKDBG_REFTABLE_LOAD);
47 47
        ret = bdrv_pread(bs->file, s->refcount_table_offset,
......
59 59
void qcow2_refcount_close(BlockDriverState *bs)
60 60
{
61 61
    BDRVQcowState *s = bs->opaque;
62
    qemu_free(s->refcount_table);
62
    g_free(s->refcount_table);
63 63
}
64 64

  
65 65

  
......
323 323
    uint64_t meta_offset = (blocks_used * refcount_block_clusters) *
324 324
        s->cluster_size;
325 325
    uint64_t table_offset = meta_offset + blocks_clusters * s->cluster_size;
326
    uint16_t *new_blocks = qemu_mallocz(blocks_clusters * s->cluster_size);
327
    uint64_t *new_table = qemu_mallocz(table_size * sizeof(uint64_t));
326
    uint16_t *new_blocks = g_malloc0(blocks_clusters * s->cluster_size);
327
    uint64_t *new_table = g_malloc0(table_size * sizeof(uint64_t));
328 328

  
329 329
    assert(meta_offset >= (s->free_cluster_index * s->cluster_size));
330 330

  
......
349 349
    BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS);
350 350
    ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
351 351
        blocks_clusters * s->cluster_size);
352
    qemu_free(new_blocks);
352
    g_free(new_blocks);
353 353
    if (ret < 0) {
354 354
        goto fail_table;
355 355
    }
......
385 385
    uint64_t old_table_offset = s->refcount_table_offset;
386 386
    uint64_t old_table_size = s->refcount_table_size;
387 387

  
388
    qemu_free(s->refcount_table);
388
    g_free(s->refcount_table);
389 389
    s->refcount_table = new_table;
390 390
    s->refcount_table_size = table_size;
391 391
    s->refcount_table_offset = table_offset;
......
403 403
    return new_block;
404 404

  
405 405
fail_table:
406
    qemu_free(new_table);
406
    g_free(new_table);
407 407
fail_block:
408 408
    if (*refcount_block != NULL) {
409 409
        qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
......
720 720
    l1_size2 = l1_size * sizeof(uint64_t);
721 721
    if (l1_table_offset != s->l1_table_offset) {
722 722
        if (l1_size2 != 0) {
723
            l1_table = qemu_mallocz(align_offset(l1_size2, 512));
723
            l1_table = g_malloc0(align_offset(l1_size2, 512));
724 724
        } else {
725 725
            l1_table = NULL;
726 726
        }
......
847 847
            be64_to_cpus(&l1_table[i]);
848 848
    }
849 849
    if (l1_allocated)
850
        qemu_free(l1_table);
850
        g_free(l1_table);
851 851
    return ret;
852 852
}
853 853

  
......
921 921

  
922 922
    /* Read L2 table from disk */
923 923
    l2_size = s->l2_size * sizeof(uint64_t);
924
    l2_table = qemu_malloc(l2_size);
924
    l2_table = g_malloc(l2_size);
925 925

  
926 926
    if (bdrv_pread(bs->file, l2_offset, l2_table, l2_size) != l2_size)
927 927
        goto fail;
......
979 979
        }
980 980
    }
981 981

  
982
    qemu_free(l2_table);
982
    g_free(l2_table);
983 983
    return 0;
984 984

  
985 985
fail:
986 986
    fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n");
987
    qemu_free(l2_table);
987
    g_free(l2_table);
988 988
    return -EIO;
989 989
}
990 990

  
......
1017 1017
    if (l1_size2 == 0) {
1018 1018
        l1_table = NULL;
1019 1019
    } else {
1020
        l1_table = qemu_malloc(l1_size2);
1020
        l1_table = g_malloc(l1_size2);
1021 1021
        if (bdrv_pread(bs->file, l1_table_offset,
1022 1022
                       l1_table, l1_size2) != l1_size2)
1023 1023
            goto fail;
......
1065 1065
            }
1066 1066
        }
1067 1067
    }
1068
    qemu_free(l1_table);
1068
    g_free(l1_table);
1069 1069
    return 0;
1070 1070

  
1071 1071
fail:
1072 1072
    fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
1073 1073
    res->check_errors++;
1074
    qemu_free(l1_table);
1074
    g_free(l1_table);
1075 1075
    return -EIO;
1076 1076
}
1077 1077

  
......
1092 1092

  
1093 1093
    size = bdrv_getlength(bs->file);
1094 1094
    nb_clusters = size_to_clusters(s, size);
1095
    refcount_table = qemu_mallocz(nb_clusters * sizeof(uint16_t));
1095
    refcount_table = g_malloc0(nb_clusters * sizeof(uint16_t));
1096 1096

  
1097 1097
    /* header */
1098 1098
    inc_refcounts(bs, res, refcount_table, nb_clusters,
......
1178 1178
    ret = 0;
1179 1179

  
1180 1180
fail:
1181
    qemu_free(refcount_table);
1181
    g_free(refcount_table);
1182 1182

  
1183 1183
    return ret;
1184 1184
}
b/block/qcow2-snapshot.c
52 52
    int i;
53 53

  
54 54
    for(i = 0; i < s->nb_snapshots; i++) {
55
        qemu_free(s->snapshots[i].name);
56
        qemu_free(s->snapshots[i].id_str);
55
        g_free(s->snapshots[i].name);
56
        g_free(s->snapshots[i].id_str);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff