diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-20 22:09:37 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-08-20 23:01:08 -0500 |
commit | 7267c0947d7e8ae5dff7bafd932c3bc285f43e5c (patch) | |
tree | 9aa05d6e05ed83e67bf014f6745a3081b8407dc5 /hw/elf_ops.h | |
parent | 14015304b662e8f8ccce46c5a6927af6a14c510b (diff) |
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>
Diffstat (limited to 'hw/elf_ops.h')
-rw-r--r-- | hw/elf_ops.h | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/hw/elf_ops.h b/hw/elf_ops.h index 0bd72350b4..6af357fc13 100644 --- a/hw/elf_ops.h +++ b/hw/elf_ops.h @@ -150,7 +150,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab, i++; } if (nsyms) { - syms = qemu_realloc(syms, nsyms * sizeof(*syms)); + syms = g_realloc(syms, nsyms * sizeof(*syms)); qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ)); for (i = 0; i < nsyms - 1; i++) { @@ -159,7 +159,7 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab, } } } else { - qemu_free(syms); + g_free(syms); syms = NULL; } @@ -173,19 +173,19 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab, goto fail; /* Commit */ - s = qemu_mallocz(sizeof(*s)); + s = g_malloc0(sizeof(*s)); s->lookup_symbol = glue(lookup_symbol, SZ); glue(s->disas_symtab.elf, SZ) = syms; s->disas_num_syms = nsyms; s->disas_strtab = str; s->next = syminfos; syminfos = s; - qemu_free(shdr_table); + g_free(shdr_table); return 0; fail: - qemu_free(syms); - qemu_free(str); - qemu_free(shdr_table); + g_free(syms); + g_free(str); + g_free(shdr_table); return -1; } @@ -238,7 +238,7 @@ static int glue(load_elf, SZ)(const char *name, int fd, size = ehdr.e_phnum * sizeof(phdr[0]); lseek(fd, ehdr.e_phoff, SEEK_SET); - phdr = qemu_mallocz(size); + phdr = g_malloc0(size); if (!phdr) goto fail; if (read(fd, phdr, size) != size) @@ -256,7 +256,7 @@ static int glue(load_elf, SZ)(const char *name, int fd, if (ph->p_type == PT_LOAD) { mem_size = ph->p_memsz; /* XXX: avoid allocating */ - data = qemu_mallocz(mem_size); + data = g_malloc0(mem_size); if (ph->p_filesz > 0) { if (lseek(fd, ph->p_offset, SEEK_SET) < 0) goto fail; @@ -280,18 +280,18 @@ static int glue(load_elf, SZ)(const char *name, int fd, if ((addr + mem_size) > high) high = addr + mem_size; - qemu_free(data); + g_free(data); data = NULL; } } - qemu_free(phdr); + g_free(phdr); if (lowaddr) *lowaddr = (uint64_t)(elf_sword)low; if (highaddr) *highaddr = (uint64_t)(elf_sword)high; return total_size; fail: - qemu_free(data); - qemu_free(phdr); + g_free(data); + g_free(phdr); return -1; } |