Skip to content

Commit

Permalink
fix: use nullptr instead of NULL
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Olivier <[email protected]>
  • Loading branch information
martin-olivier committed Dec 27, 2024
1 parent 2e696cc commit c806620
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/demangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ std::string get_demangled_name(const char *symbol) {
char *res;

buf = (char *)(malloc(size));
if (buf == NULL)
if (!buf)
throw std::bad_alloc();

res = abi::__cxa_demangle(symbol, buf, &size, &status);
Expand Down
12 changes: 6 additions & 6 deletions src/symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ static std::vector<std::string> get_symbols_at_off(void *handle, int fd, bool de
lseek(fd, current_command_offset - sizeof(lc), SEEK_SET);
read(fd, &symtab, sizeof(symtab));

struct nlist_64 *symbols64 = NULL;
struct nlist *symbols = NULL;
struct nlist_64 *symbols64 = nullptr;
struct nlist *symbols = nullptr;
if (is_64_bit) {
symbols64 = (struct nlist_64 *)(malloc(symtab.nsyms * sizeof(struct nlist_64)));
if (symbols64 == nullptr)
Expand Down Expand Up @@ -215,7 +215,7 @@ std::vector<std::string> get_symbols(void *handle, int fd, bool demangle, bool l
if (elf_version(EV_CURRENT) == EV_NONE)
throw std::string("ELF library initialization failed");

Elf *elf = elf_begin(fd, ELF_C_READ, NULL);
Elf *elf = elf_begin(fd, ELF_C_READ, nullptr);
if (!elf)
throw std::string("elf_begin() failed");

Expand All @@ -225,16 +225,16 @@ std::vector<std::string> get_symbols(void *handle, int fd, bool demangle, bool l
throw std::string("elf_getshdrstrndx() failed");
}

Elf_Scn *scn = NULL;
Elf_Scn *scn = nullptr;
GElf_Shdr shdr;
while ((scn = elf_nextscn(elf, scn)) != NULL) {
while ((scn = elf_nextscn(elf, scn))) {
if (gelf_getshdr(scn, &shdr) != &shdr) {
elf_end(elf);
throw std::string("gelf_getshdr() failed");
}

if (shdr.sh_type == SHT_SYMTAB || shdr.sh_type == SHT_DYNSYM) {
Elf_Data *data = elf_getdata(scn, NULL);
Elf_Data *data = elf_getdata(scn, nullptr);
if (!data) {
elf_end(elf);
throw std::string("elf_getdata() failed");
Expand Down

0 comments on commit c806620

Please sign in to comment.