mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 14:23:53 -06:00
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
14015304b6
commit
7267c0947d
357 changed files with 1672 additions and 1674 deletions
48
hw/loader.c
48
hw/loader.c
|
@ -91,11 +91,11 @@ int read_targphys(const char *name,
|
|||
uint8_t *buf;
|
||||
size_t did;
|
||||
|
||||
buf = qemu_malloc(nbytes);
|
||||
buf = g_malloc(nbytes);
|
||||
did = read(fd, buf, nbytes);
|
||||
if (did > 0)
|
||||
rom_add_blob_fixed("read", buf, did, dst_addr);
|
||||
qemu_free(buf);
|
||||
g_free(buf);
|
||||
return did;
|
||||
}
|
||||
|
||||
|
@ -234,9 +234,9 @@ static void *load_at(int fd, int offset, int size)
|
|||
void *ptr;
|
||||
if (lseek(fd, offset, SEEK_SET) < 0)
|
||||
return NULL;
|
||||
ptr = qemu_malloc(size);
|
||||
ptr = g_malloc(size);
|
||||
if (read(fd, ptr, size) != size) {
|
||||
qemu_free(ptr);
|
||||
g_free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
return ptr;
|
||||
|
@ -351,14 +351,14 @@ static void *zalloc(void *x, unsigned items, unsigned size)
|
|||
size *= items;
|
||||
size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
|
||||
|
||||
p = qemu_malloc(size);
|
||||
p = g_malloc(size);
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
static void zfree(void *x, void *addr)
|
||||
{
|
||||
qemu_free(addr);
|
||||
g_free(addr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -476,7 +476,7 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
|
|||
}
|
||||
|
||||
*ep = hdr->ih_ep;
|
||||
data = qemu_malloc(hdr->ih_size);
|
||||
data = g_malloc(hdr->ih_size);
|
||||
|
||||
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
|
||||
fprintf(stderr, "Error reading file\n");
|
||||
|
@ -490,10 +490,10 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
|
|||
|
||||
compressed_data = data;
|
||||
max_bytes = UBOOT_MAX_GUNZIP_BYTES;
|
||||
data = qemu_malloc(max_bytes);
|
||||
data = g_malloc(max_bytes);
|
||||
|
||||
bytes = gunzip(data, max_bytes, compressed_data, hdr->ih_size);
|
||||
qemu_free(compressed_data);
|
||||
g_free(compressed_data);
|
||||
if (bytes < 0) {
|
||||
fprintf(stderr, "Unable to decompress gzipped image!\n");
|
||||
goto out;
|
||||
|
@ -510,7 +510,7 @@ int load_uimage(const char *filename, target_phys_addr_t *ep,
|
|||
|
||||
out:
|
||||
if (data)
|
||||
qemu_free(data);
|
||||
g_free(data);
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
@ -564,11 +564,11 @@ int rom_add_file(const char *file, const char *fw_dir,
|
|||
int rc, fd = -1;
|
||||
char devpath[100];
|
||||
|
||||
rom = qemu_mallocz(sizeof(*rom));
|
||||
rom->name = qemu_strdup(file);
|
||||
rom = g_malloc0(sizeof(*rom));
|
||||
rom->name = g_strdup(file);
|
||||
rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
|
||||
if (rom->path == NULL) {
|
||||
rom->path = qemu_strdup(file);
|
||||
rom->path = g_strdup(file);
|
||||
}
|
||||
|
||||
fd = open(rom->path, O_RDONLY | O_BINARY);
|
||||
|
@ -579,12 +579,12 @@ int rom_add_file(const char *file, const char *fw_dir,
|
|||
}
|
||||
|
||||
if (fw_dir) {
|
||||
rom->fw_dir = qemu_strdup(fw_dir);
|
||||
rom->fw_file = qemu_strdup(file);
|
||||
rom->fw_dir = g_strdup(fw_dir);
|
||||
rom->fw_file = g_strdup(file);
|
||||
}
|
||||
rom->addr = addr;
|
||||
rom->romsize = lseek(fd, 0, SEEK_END);
|
||||
rom->data = qemu_mallocz(rom->romsize);
|
||||
rom->data = g_malloc0(rom->romsize);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
rc = read(fd, rom->data, rom->romsize);
|
||||
if (rc != rom->romsize) {
|
||||
|
@ -618,10 +618,10 @@ int rom_add_file(const char *file, const char *fw_dir,
|
|||
err:
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
qemu_free(rom->data);
|
||||
qemu_free(rom->path);
|
||||
qemu_free(rom->name);
|
||||
qemu_free(rom);
|
||||
g_free(rom->data);
|
||||
g_free(rom->path);
|
||||
g_free(rom->name);
|
||||
g_free(rom);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -630,11 +630,11 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
|
|||
{
|
||||
Rom *rom;
|
||||
|
||||
rom = qemu_mallocz(sizeof(*rom));
|
||||
rom->name = qemu_strdup(name);
|
||||
rom = g_malloc0(sizeof(*rom));
|
||||
rom->name = g_strdup(name);
|
||||
rom->addr = addr;
|
||||
rom->romsize = len;
|
||||
rom->data = qemu_mallocz(rom->romsize);
|
||||
rom->data = g_malloc0(rom->romsize);
|
||||
memcpy(rom->data, blob, len);
|
||||
rom_insert(rom);
|
||||
return 0;
|
||||
|
@ -664,7 +664,7 @@ static void rom_reset(void *unused)
|
|||
cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
|
||||
if (rom->isrom) {
|
||||
/* rom needs to be written only once */
|
||||
qemu_free(rom->data);
|
||||
g_free(rom->data);
|
||||
rom->data = NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue