From befc631d04bc580555a0892a8c3746c9cf1d20eb Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 28 Feb 2011 09:45:43 +0300 Subject: elf64: Use nasm_zalloc helper Signed-off-by: Cyrill Gorcunov --- output/outelf64.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'output') diff --git a/output/outelf64.c b/output/outelf64.c index 9807c2a..46cc6aa 100644 --- a/output/outelf64.c +++ b/output/outelf64.c @@ -308,25 +308,21 @@ static int elf_make_section(char *name, int type, int flags, int align) { struct Section *s; - s = nasm_malloc(sizeof(*s)); + s = nasm_zalloc(sizeof(*s)); if (type != SHT_NOBITS) s->data = saa_init(1L); - s->head = NULL; s->tail = &s->head; - s->len = s->size = 0; - s->nrelocs = 0; if (!strcmp(name, ".text")) s->index = def_seg; else s->index = seg_alloc(); add_sectname("", name); - s->name = nasm_malloc(1 + strlen(name)); - strcpy(s->name, name); - s->type = type; - s->flags = flags; - s->align = align; - s->gsyms = NULL; + + s->name = nasm_strdup(name); + s->type = type; + s->flags = flags; + s->align = align; if (nsects >= sectlen) sects = nasm_realloc(sects, (sectlen += SECT_DELTA) * sizeof(*sects)); @@ -614,17 +610,15 @@ static void elf_add_reloc(struct Section *sect, int32_t segment, int64_t offset, int type) { struct Reloc *r; - r = *sect->tail = nasm_malloc(sizeof(struct Reloc)); + + r = *sect->tail = nasm_zalloc(sizeof(struct Reloc)); sect->tail = &r->next; - r->next = NULL; r->address = sect->len; r->offset = offset; - if (segment == NO_SEG) - r->symbol = 0; - else { + + if (segment != NO_SEG) { int i; - r->symbol = 0; for (i = 0; i < nsects; i++) if (segment == sects[i]->index) r->symbol = i + 2; @@ -1692,9 +1686,7 @@ static void stabs64_generate(void) ptr = stabslines; - allfiles = (char **)nasm_malloc(numlinestabs * sizeof(char *)); - for (i = 0; i < numlinestabs; i++) - allfiles[i] = 0; + allfiles = (char **)nasm_zalloc(numlinestabs * sizeof(char *)); numfiles = 0; while (ptr) { if (numfiles == 0) { -- cgit v1.2.3