Revision 7267c094 hw/loader.c

b/hw/loader.c
91 91
    uint8_t *buf;
92 92
    size_t did;
93 93

  
94
    buf = qemu_malloc(nbytes);
94
    buf = g_malloc(nbytes);
95 95
    did = read(fd, buf, nbytes);
96 96
    if (did > 0)
97 97
        rom_add_blob_fixed("read", buf, did, dst_addr);
98
    qemu_free(buf);
98
    g_free(buf);
99 99
    return did;
100 100
}
101 101

  
......
234 234
    void *ptr;
235 235
    if (lseek(fd, offset, SEEK_SET) < 0)
236 236
        return NULL;
237
    ptr = qemu_malloc(size);
237
    ptr = g_malloc(size);
238 238
    if (read(fd, ptr, size) != size) {
239
        qemu_free(ptr);
239
        g_free(ptr);
240 240
        return NULL;
241 241
    }
242 242
    return ptr;
......
351 351
    size *= items;
352 352
    size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
353 353

  
354
    p = qemu_malloc(size);
354
    p = g_malloc(size);
355 355

  
356 356
    return (p);
357 357
}
358 358

  
359 359
static void zfree(void *x, void *addr)
360 360
{
361
    qemu_free(addr);
361
    g_free(addr);
362 362
}
363 363

  
364 364

  
......
476 476
    }
477 477

  
478 478
    *ep = hdr->ih_ep;
479
    data = qemu_malloc(hdr->ih_size);
479
    data = g_malloc(hdr->ih_size);
480 480

  
481 481
    if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
482 482
        fprintf(stderr, "Error reading file\n");
......
490 490

  
491 491
        compressed_data = data;
492 492
        max_bytes = UBOOT_MAX_GUNZIP_BYTES;
493
        data = qemu_malloc(max_bytes);
493
        data = g_malloc(max_bytes);
494 494

  
495 495
        bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size);
496
        qemu_free(compressed_data);
496
        g_free(compressed_data);
497 497
        if (bytes < 0) {
498 498
            fprintf(stderr, "Unable to decompress gzipped image!\n");
499 499
            goto out;
......
510 510

  
511 511
out:
512 512
    if (data)
513
        qemu_free(data);
513
        g_free(data);
514 514
    close(fd);
515 515
    return ret;
516 516
}
......
564 564
    int rc, fd = -1;
565 565
    char devpath[100];
566 566

  
567
    rom = qemu_mallocz(sizeof(*rom));
568
    rom->name = qemu_strdup(file);
567
    rom = g_malloc0(sizeof(*rom));
568
    rom->name = g_strdup(file);
569 569
    rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
570 570
    if (rom->path == NULL) {
571
        rom->path = qemu_strdup(file);
571
        rom->path = g_strdup(file);
572 572
    }
573 573

  
574 574
    fd = open(rom->path, O_RDONLY | O_BINARY);
......
579 579
    }
580 580

  
581 581
    if (fw_dir) {
582
        rom->fw_dir  = qemu_strdup(fw_dir);
583
        rom->fw_file = qemu_strdup(file);
582
        rom->fw_dir  = g_strdup(fw_dir);
583
        rom->fw_file = g_strdup(file);
584 584
    }
585 585
    rom->addr    = addr;
586 586
    rom->romsize = lseek(fd, 0, SEEK_END);
587
    rom->data    = qemu_mallocz(rom->romsize);
587
    rom->data    = g_malloc0(rom->romsize);
588 588
    lseek(fd, 0, SEEK_SET);
589 589
    rc = read(fd, rom->data, rom->romsize);
590 590
    if (rc != rom->romsize) {
......
618 618
err:
619 619
    if (fd != -1)
620 620
        close(fd);
621
    qemu_free(rom->data);
622
    qemu_free(rom->path);
623
    qemu_free(rom->name);
624
    qemu_free(rom);
621
    g_free(rom->data);
622
    g_free(rom->path);
623
    g_free(rom->name);
624
    g_free(rom);
625 625
    return -1;
626 626
}
627 627

  
......
630 630
{
631 631
    Rom *rom;
632 632

  
633
    rom = qemu_mallocz(sizeof(*rom));
634
    rom->name    = qemu_strdup(name);
633
    rom = g_malloc0(sizeof(*rom));
634
    rom->name    = g_strdup(name);
635 635
    rom->addr    = addr;
636 636
    rom->romsize = len;
637
    rom->data    = qemu_mallocz(rom->romsize);
637
    rom->data    = g_malloc0(rom->romsize);
638 638
    memcpy(rom->data, blob, len);
639 639
    rom_insert(rom);
640 640
    return 0;
......
664 664
        cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
665 665
        if (rom->isrom) {
666 666
            /* rom needs to be written only once */
667
            qemu_free(rom->data);
667
            g_free(rom->data);
668 668
            rom->data = NULL;
669 669
        }
670 670
    }

Also available in: Unified diff