Signed-off-by: Annapoornima Koppad <annakop...@gmail.com> --- block/iscsi.c | 2 +- bsd-user/elfload.c | 12 ++++++------ disas/libvixl/vixl/a64/disasm-a64.cc | 2 +- disas/m68k.c | 2 +- disas/sparc.c | 4 ++-- hw/audio/fmopl.c | 10 +++++----- hw/usb/redirect.c | 2 +- include/exec/softmmu-semi.h | 4 ++-- linux-user/elfload.c | 2 +- linux-user/syscall.c | 2 +- slirp/mbuf.c | 4 ++-- slirp/sbuf.c | 2 +- slirp/socket.c | 2 +- slirp/tcp_subr.c | 2 +- tests/migration/stress.c | 4 ++-- tests/tcg/cris/check_openpf1.c | 2 +- tests/tcg/linux-test.c | 4 ++-- tests/tcg/test-mmap.c | 2 +- thunk.c | 2 +- util/compatfd.c | 2 +- util/envlist.c | 6 +++--- 21 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c index dff548a..21cb41b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -963,7 +963,7 @@ static BlockAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, return NULL; } - acb->task = malloc(sizeof(struct scsi_task)); + acb->task = g_malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { error_report("iSCSI: Failed to allocate task for scsi command. %s", iscsi_get_error(iscsi)); diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 41a1309..5fdded2 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -868,7 +868,7 @@ static abi_ulong load_elf_interp(struct elfhdr * interp_elf_ex, return ~(abi_ulong)0UL; elf_phdata = (struct elf_phdr *) - malloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); + g_malloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); if (!elf_phdata) return ~((abi_ulong)0UL); @@ -1064,13 +1064,13 @@ static void load_symbols(struct elfhdr *hdr, int fd) found: /* Now know where the strtab and symtab are. Snarf them. */ - s = malloc(sizeof(*s)); - syms = malloc(symtab.sh_size); + s = g_malloc(sizeof(*s)); + syms = g_malloc(symtab.sh_size); if (!syms) { free(s); return; } - s->disas_strtab = strings = malloc(strtab.sh_size); + s->disas_strtab = strings = g_malloc(strtab.sh_size); if (!s->disas_strtab) { free(s); free(syms); @@ -1191,7 +1191,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, } /* Now read in all of the header information */ - elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum); + elf_phdata = (struct elf_phdr *)g_malloc(elf_ex.e_phentsize*elf_ex.e_phnum); if (elf_phdata == NULL) { return -ENOMEM; } @@ -1244,7 +1244,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, * is an a.out format binary */ - elf_interpreter = (char *)malloc(elf_ppnt->p_filesz); + elf_interpreter = (char *)g_malloc(elf_ppnt->p_filesz); if (elf_interpreter == NULL) { free (elf_phdata); diff --git a/disas/libvixl/vixl/a64/disasm-a64.cc b/disas/libvixl/vixl/a64/disasm-a64.cc index 7a58a5c..4127d72 100644 --- a/disas/libvixl/vixl/a64/disasm-a64.cc +++ b/disas/libvixl/vixl/a64/disasm-a64.cc @@ -31,7 +31,7 @@ namespace vixl { Disassembler::Disassembler() { buffer_size_ = 256; - buffer_ = reinterpret_cast<char*>(malloc(buffer_size_)); + buffer_ = reinterpret_cast<char*>(g_malloc(buffer_size_)); buffer_pos_ = 0; own_buffer_ = true; code_address_offset_ = 0; diff --git a/disas/m68k.c b/disas/m68k.c index 8e7c3f7..25dfc8d 100644 --- a/disas/m68k.c +++ b/disas/m68k.c @@ -1886,7 +1886,7 @@ print_insn_m68k (bfd_vma memaddr, disassemble_info *info) /* Then create a sorted table of pointers that point into the unsorted table. */ - opc_pointer[0] = malloc (sizeof (struct m68k_opcode *) + opc_pointer[0] = g_malloc (sizeof (struct m68k_opcode *) * m68k_numopcodes); opcodes[0] = opc_pointer[0]; diff --git a/disas/sparc.c b/disas/sparc.c index f120f4e..9c7ce9c 100644 --- a/disas/sparc.c +++ b/disas/sparc.c @@ -2623,7 +2623,7 @@ build_hash_table (const sparc_opcode **opcode_table, memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0])); memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0])); free(hash_buf); - hash_buf = malloc (sizeof (* hash_buf) * num_opcodes); + hash_buf = g_malloc (sizeof (* hash_buf) * num_opcodes); for (i = num_opcodes - 1; i >= 0; --i) { int hash = HASH_INSN (opcode_table[i]->match); @@ -2685,7 +2685,7 @@ print_insn_sparc (bfd_vma memaddr, disassemble_info *info) if (!opcodes_initialized) sorted_opcodes = - malloc (sparc_num_opcodes * sizeof (sparc_opcode *)); + g_malloc (sparc_num_opcodes * sizeof (sparc_opcode *)); /* Reset the sorted table so we can resort it. */ for (i = 0; i < sparc_num_opcodes; ++i) sorted_opcodes[i] = &sparc_opcodes[i]; diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c index 731110f..3ce6c14 100644 --- a/hw/audio/fmopl.c +++ b/hw/audio/fmopl.c @@ -618,20 +618,20 @@ static int OPLOpenTable( void ) double pom; /* allocate dynamic tables */ - if( (TL_TABLE = malloc(TL_MAX*2*sizeof(INT32))) == NULL) + if( (TL_TABLE = g_malloc(TL_MAX*2*sizeof(INT32))) == NULL) return 0; - if( (SIN_TABLE = malloc(SIN_ENT*4 *sizeof(INT32 *))) == NULL) + if( (SIN_TABLE = g_malloc(SIN_ENT*4 *sizeof(INT32 *))) == NULL) { free(TL_TABLE); return 0; } - if( (AMS_TABLE = malloc(AMS_ENT*2 *sizeof(INT32))) == NULL) + if( (AMS_TABLE = g_malloc(AMS_ENT*2 *sizeof(INT32))) == NULL) { free(TL_TABLE); free(SIN_TABLE); return 0; } - if( (VIB_TABLE = malloc(VIB_ENT*2 *sizeof(INT32))) == NULL) + if( (VIB_TABLE = g_malloc(VIB_ENT*2 *sizeof(INT32))) == NULL) { free(TL_TABLE); free(SIN_TABLE); @@ -1220,7 +1220,7 @@ FM_OPL *OPLCreate(int type, int clock, int rate) if(type&OPL_TYPE_ADPCM) state_size+= sizeof(YM_DELTAT); #endif /* allocate memory block */ - ptr = malloc(state_size); + ptr = g_malloc(state_size); if(ptr==NULL) return NULL; /* clear */ memset(ptr,0,state_size); diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 444672a..63740b5 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -2250,7 +2250,7 @@ static int usbredir_get_bufpq(QEMUFile *f, void *priv, size_t unused) bufp->len = qemu_get_be32(f); bufp->status = qemu_get_be32(f); bufp->offset = 0; - bufp->data = qemu_oom_check(malloc(bufp->len)); /* regular malloc! */ + bufp->data = qemu_oom_check(g_malloc(bufp->len)); /* regular malloc! */ bufp->free_on_destroy = bufp->data; qemu_get_buffer(f, bufp->data, bufp->len); QTAILQ_INSERT_TAIL(&endp->bufpq, bufp, next); diff --git a/include/exec/softmmu-semi.h b/include/exec/softmmu-semi.h index 7eefad8..3d60c76 100644 --- a/include/exec/softmmu-semi.h +++ b/include/exec/softmmu-semi.h @@ -61,7 +61,7 @@ static void *softmmu_lock_user(CPUArchState *env, { uint8_t *p; /* TODO: Make this something that isn't fixed size. */ - p = malloc(len); + p = g_malloc(len); if (p && copy) { cpu_memory_rw_debug(ENV_GET_CPU(env), addr, p, len, 0); } @@ -74,7 +74,7 @@ static char *softmmu_lock_user_string(CPUArchState *env, target_ulong addr) char *s; uint8_t c; /* TODO: Make this something that isn't fixed size. */ - s = p = malloc(1024); + s = p = g_malloc(1024); if (!s) { return NULL; } diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 816272a..03f270d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1969,7 +1969,7 @@ static void load_elf_image(const char *image_name, int image_fd, errmsg = "Multiple PT_INTERP entries"; goto exit_errmsg; } - interp_name = malloc(eppnt->p_filesz); + interp_name = g_malloc(eppnt->p_filesz); if (!interp_name) { goto exit_perror; } diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0815f30..9508f5d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5025,7 +5025,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, /* We can't fit all the extents into the fixed size buffer. * Allocate one that is large enough and use it instead. */ - host_ifconf = malloc(outbufsz); + host_ifconf = g_malloc(outbufsz); if (!host_ifconf) { return -TARGET_ENOMEM; } diff --git a/slirp/mbuf.c b/slirp/mbuf.c index 7eddc21..1c580a1 100644 --- a/slirp/mbuf.c +++ b/slirp/mbuf.c @@ -71,7 +71,7 @@ m_get(Slirp *slirp) DEBUG_CALL("m_get"); if (slirp->m_freelist.qh_link == &slirp->m_freelist) { - m = (struct mbuf *)malloc(SLIRP_MSIZE); + m = (struct mbuf *)g_malloc(SLIRP_MSIZE); if (m == NULL) goto end_error; slirp->mbuf_alloced++; if (slirp->mbuf_alloced > MBUF_THRESH) @@ -165,7 +165,7 @@ m_inc(struct mbuf *m, int size) } else { char *dat; datasize = m->m_data - m->m_dat; - dat = (char *)malloc(size); + dat = (char *)g_malloc(size); memcpy(dat, m->m_dat, m->m_size); m->m_ext = dat; diff --git a/slirp/sbuf.c b/slirp/sbuf.c index 10119d3..b53f36b 100644 --- a/slirp/sbuf.c +++ b/slirp/sbuf.c @@ -52,7 +52,7 @@ sbreserve(struct sbuf *sb, int size) sb->sb_datalen = 0; } } else { - sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)malloc(size); + sb->sb_wptr = sb->sb_rptr = sb->sb_data = (char *)g_malloc(size); sb->sb_cc = 0; if (sb->sb_wptr) sb->sb_datalen = size; diff --git a/slirp/socket.c b/slirp/socket.c index 280050a..9650f64 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -48,7 +48,7 @@ socreate(Slirp *slirp) { struct socket *so; - so = (struct socket *)malloc(sizeof(struct socket)); + so = (struct socket *)g_malloc(sizeof(struct socket)); if(so) { memset(so, 0, sizeof(struct socket)); so->so_state = SS_NOFDREF; diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index ed16e18..3330108 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -247,7 +247,7 @@ tcp_newtcpcb(struct socket *so) { register struct tcpcb *tp; - tp = (struct tcpcb *)malloc(sizeof(*tp)); + tp = (struct tcpcb *)g_malloc(sizeof(*tp)); if (tp == NULL) return ((struct tcpcb *)0); diff --git a/tests/migration/stress.c b/tests/migration/stress.c index cf8ce8b..6cef393 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -178,10 +178,10 @@ static unsigned long long now(void) static int stressone(unsigned long long ramsizeMB) { size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE; - char *ram = malloc(ramsizeMB * 1024 * 1024); + char *ram = g_malloc(ramsizeMB * 1024 * 1024); char *ramptr; size_t i, j, k; - char *data = malloc(PAGE_SIZE); + char *data = g_malloc(PAGE_SIZE); char *dataptr; size_t nMB = 0; unsigned long long before, after; diff --git a/tests/tcg/cris/check_openpf1.c b/tests/tcg/cris/check_openpf1.c index fdcf4c5..60eb9e0 100644 --- a/tests/tcg/cris/check_openpf1.c +++ b/tests/tcg/cris/check_openpf1.c @@ -17,7 +17,7 @@ int main (int argc, char *argv[]) FILE *f; if (argv[0][0] != '/') { - fnam = malloc (strlen (argv[0]) + 2); + fnam = g_malloc (strlen (argv[0]) + 2); if (fnam == NULL) abort (); strcpy (fnam, "/"); diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c index 5070d31..6b270af 100644 --- a/tests/tcg/linux-test.c +++ b/tests/tcg/linux-test.c @@ -419,11 +419,11 @@ void test_clone(void) uint8_t *stack1, *stack2; int pid1, pid2, status1, status2; - stack1 = malloc(STACK_SIZE); + stack1 = g_malloc(STACK_SIZE); pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1")); - stack2 = malloc(STACK_SIZE); + stack2 = g_malloc(STACK_SIZE); pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2")); diff --git a/tests/tcg/test-mmap.c b/tests/tcg/test-mmap.c index 3982fa2..7ce063e 100644 --- a/tests/tcg/test-mmap.c +++ b/tests/tcg/test-mmap.c @@ -449,7 +449,7 @@ int main(int argc, char **argv) /* Assume pagesize is a power of two. */ pagemask = pagesize - 1; - dummybuf = malloc (pagesize); + dummybuf = g_malloc (pagesize); printf ("pagesize=%u pagemask=%x\n", pagesize, pagemask); test_fd = mkstemp(tempname); diff --git a/thunk.c b/thunk.c index 2dac366..db1f3ba 100644 --- a/thunk.c +++ b/thunk.c @@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types) for(i = 0;i < 2; i++) { offset = 0; max_align = 1; - se->field_offsets[i] = malloc(nb_fields * sizeof(int)); + se->field_offsets[i] = g_malloc(nb_fields * sizeof(int)); type_ptr = se->field_types; for(j = 0;j < nb_fields; j++) { size = thunk_type_size(type_ptr, i); diff --git a/util/compatfd.c b/util/compatfd.c index 9a43042..e8b6cd1 100644 --- a/util/compatfd.c +++ b/util/compatfd.c @@ -72,7 +72,7 @@ static int qemu_signalfd_compat(const sigset_t *mask) QemuThread thread; int fds[2]; - info = malloc(sizeof(*info)); + info = g_malloc(sizeof(*info)); if (info == NULL) { errno = ENOMEM; return -1; diff --git a/util/envlist.c b/util/envlist.c index e86857e..4cd47cd 100644 --- a/util/envlist.c +++ b/util/envlist.c @@ -25,7 +25,7 @@ envlist_create(void) { envlist_t *envlist; - if ((envlist = malloc(sizeof (*envlist))) == NULL) + if ((envlist = g_malloc(sizeof (*envlist))) == NULL) return (NULL); QLIST_INIT(&envlist->el_entries); @@ -161,7 +161,7 @@ envlist_setenv(envlist_t *envlist, const char *env) envlist->el_count++; } - if ((entry = malloc(sizeof (*entry))) == NULL) + if ((entry = g_malloc(sizeof (*entry))) == NULL) return (errno); if ((entry->ev_var = strdup(env)) == NULL) { free(entry); @@ -225,7 +225,7 @@ envlist_to_environ(const envlist_t *envlist, size_t *count) struct envlist_entry *entry; char **env, **penv; - penv = env = malloc((envlist->el_count + 1) * sizeof (char *)); + penv = env = g_malloc((envlist->el_count + 1) * sizeof (char *)); if (env == NULL) return (NULL); -- 2.7.4