From 0a7e5b1473ba3e0448328c3bf3c26f9ecfc6ab86 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 26 Sep 2011 16:51:37 -0300 Subject: [PATCH] m1/perf/sched.c: use calloc instead of malloc plus memset --- m1/perf/sched.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/m1/perf/sched.c b/m1/perf/sched.c index ffe57c9..e7cc6db 100644 --- a/m1/perf/sched.c +++ b/m1/perf/sched.c @@ -315,14 +315,12 @@ static void mark(int vm_reg) static void init_registers(struct fpvm_fragment *frag, unsigned int *registers) { - size_t regs_size; int i; get_registers(frag, registers); - regs_size = sizeof(struct vm_reg)*(frag->nbindings-frag->next_sur); - sc->regs = malloc(regs_size); - memset(sc->regs, 0, regs_size); + sc->regs = + calloc(frag->nbindings-frag->next_sur, sizeof(struct vm_reg)); for (i = 0; i != frag->ninstructions; i++) { mark(frag->code[i].opa); @@ -614,8 +612,7 @@ static int schedule(unsigned int *code) static void init_scheduler_context(struct fpvm_fragment *frag, unsigned int *reg) { - sc = malloc(sizeof(*sc)); - memset(sc, 0, sizeof(*sc)); + sc = calloc(1, sizeof(*sc)); sc->frag = frag;