Skip to content

Commit

Permalink
fix: change reinterpret casts into C casts
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Olivier <[email protected]>
  • Loading branch information
martin-olivier committed Jul 30, 2024
1 parent a1ab069 commit 2dce2f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/demangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::string get_demangled_name(const char *symbol) {
char *buf;
char *res;

buf = reinterpret_cast<char *>(malloc(size));
buf = (char *)(malloc(size));
if (buf == NULL)
throw std::bad_alloc();

Expand Down
8 changes: 4 additions & 4 deletions src/symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,22 @@ static std::vector<std::string> get_symbols_at_off(int fd, bool demangle, off_t
struct nlist_64 *symbols64 = NULL;
struct nlist *symbols = NULL;
if (is_64_bit) {
symbols64 = reinterpret_cast<struct nlist_64 *>(malloc(symtab.nsyms * sizeof(struct nlist_64)));
symbols64 = (struct nlist_64 *)(malloc(symtab.nsyms * sizeof(struct nlist_64)));
if (symbols64 == nullptr)
throw std::bad_alloc();

lseek(fd, offset + symtab.symoff, SEEK_SET);
read(fd, symbols64, symtab.nsyms * sizeof(struct nlist_64));
} else {
symbols = reinterpret_cast<struct nlist *>(malloc(symtab.nsyms * sizeof(struct nlist)));
symbols = (struct nlist *)(malloc(symtab.nsyms * sizeof(struct nlist)));
if (symbols == nullptr)
throw std::bad_alloc();

lseek(fd, offset + symtab.symoff, SEEK_SET);
read(fd, symbols, symtab.nsyms * sizeof(struct nlist));
}

char *strtab = reinterpret_cast<char *>(malloc(symtab.strsize));
char *strtab = (char *)(malloc(symtab.strsize));
if (strtab == nullptr)
throw std::bad_alloc();

Expand Down Expand Up @@ -171,7 +171,7 @@ std::vector<std::string> get_symbols(int fd, bool demangle) {
struct fat_header fat_header;
read(fd, &fat_header, sizeof(fat_header));

struct fat_arch *fat_arches = reinterpret_cast<struct fat_arch *>(malloc(sizeof(struct fat_arch) * ntohl(fat_header.nfat_arch)));
struct fat_arch *fat_arches = (struct fat_arch *)(malloc(sizeof(struct fat_arch) * ntohl(fat_header.nfat_arch)));
if (fat_arches == nullptr)
throw std::bad_alloc();
read(fd, fat_arches, sizeof(struct fat_arch) * ntohl(fat_header.nfat_arch));
Expand Down

0 comments on commit 2dce2f9

Please sign in to comment.