Skip to content

Commit

Permalink
More span
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Nov 10, 2023
1 parent 1a1d2ec commit ad50afb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions api/python/src/ELF/objects/pyNote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ void create<Note>(nb::module_& m) {

.def_prop_rw("description",
[] (const Note& self) {
const std::vector<uint8_t>& content = self.description();
return nb::memoryview::from_memory(content.data(), content.size());
return nb::to_memoryview(self.description());
},
nb::overload_cast<Note::description_t>(&Note::description),
"Return the description associated with the note"_doc)
Expand Down
5 changes: 3 additions & 2 deletions include/LIEF/ELF/Note.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "LIEF/Object.hpp"
#include "LIEF/visibility.h"
#include "LIEF/errors.hpp"
#include "LIEF/span.hpp"

#include "LIEF/ELF/enums.hpp"

Expand Down Expand Up @@ -185,11 +186,11 @@ class LIEF_API Note : public Object {
}

//! Return the description associated with the note
const description_t& description() const {
span<const uint8_t> description() const {
return description_;
}

description_t& description() {
span<uint8_t> description() {
return description_;
}

Expand Down
1 change: 0 additions & 1 deletion include/LIEF/ELF/SysvHash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class LIEF_API SysvHash : public Object {
chains_.resize(nb);
}


void accept(Visitor& visitor) const override;

LIEF_API friend std::ostream& operator<<(std::ostream& os, const SysvHash& sysvhash);
Expand Down
2 changes: 1 addition & 1 deletion src/ELF/ExeLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
raw_notes.align(sizeof(uint32_t), 0);

// description content (manipulated in 4 byte/uint32_t chunks)
const std::vector<uint8_t>& description = note.description();
span<const uint8_t> description = note.description();
const auto* desc_ptr = reinterpret_cast<const uint32_t*>(description.data());
size_t i = 0;
for (; i < description.size() / sizeof(uint32_t); i++) {
Expand Down

0 comments on commit ad50afb

Please sign in to comment.