X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Flttng-elf.cpp;h=ba8d80bb5abef8f4678343a2c3570157da59ecfc;hb=64803277bbdbe0a943360d918298a48157d9da55;hp=47d66936f9b9356c772da348f71ef849850e5dd9;hpb=60f1b42d6280b6bd386abb726dca4fd3b31d8491;p=lttng-tools.git diff --git a/src/common/lttng-elf.cpp b/src/common/lttng-elf.cpp index 47d66936f..ba8d80bb5 100644 --- a/src/common/lttng-elf.cpp +++ b/src/common/lttng-elf.cpp @@ -394,7 +394,7 @@ end: * We found the length of the section name, now seek back to the * beginning of the name and copy it in the newly allocated buffer. */ - name = (char *)zmalloc(sizeof(char) * (name_length + 1)); /* + 1 for \0 */ + name = calloc((name_length + 1)); /* + 1 for \0 */ if (!name) { PERROR("Error allocating ELF section name buffer"); goto error; @@ -495,7 +495,7 @@ int lttng_elf_validate_and_populate(struct lttng_elf *elf) goto end; } - elf->ehdr = (lttng_elf_ehdr *) zmalloc(sizeof(struct lttng_elf_ehdr)); + elf->ehdr = zmalloc(); if (!elf->ehdr) { PERROR("Error allocation buffer for ELF header"); ret = LTTNG_ERR_NOMEM; @@ -548,7 +548,7 @@ struct lttng_elf *lttng_elf_create(int fd) goto error; } - elf = (lttng_elf *) zmalloc(sizeof(struct lttng_elf)); + elf = zmalloc(); if (!elf) { PERROR("Error allocating struct lttng_elf"); goto error; @@ -664,7 +664,7 @@ char *lttng_elf_get_section_data(struct lttng_elf *elf, max_alloc_size); goto error; } - data = (char *) zmalloc(shdr->sh_size); + data = calloc(shdr->sh_size); if (!data) { PERROR("Error allocating buffer for ELF section data"); goto error;