Skip to content

Commit

Permalink
Start using RzPVector and CutterPVector instead of RzList
Browse files Browse the repository at this point in the history
  • Loading branch information
DMaroo committed Sep 20, 2023
1 parent 76a0f06 commit d232542
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
11 changes: 5 additions & 6 deletions src/core/Cutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3109,14 +3109,14 @@ QList<ImportDescription> CutterCore::getAllImports()
if (!bf) {
return {};
}
const auto *imports = new CutterPVector<RzBinImport>(rz_bin_object_get_imports(bf->o));
const RzPVector *imports = rz_bin_object_get_imports(bf->o);
if (!imports) {
return {};
}

QList<ImportDescription> qList;
bool va = core->io->va || core->bin->is_debugger;
for (auto import : *imports) {
for (const auto &import : CutterPVector<RzBinImport>(imports)) {
if (RZ_STR_ISEMPTY(import->name)) {
continue;
}
Expand Down Expand Up @@ -3557,17 +3557,16 @@ QList<BinClassDescription> CutterCore::getAllClassesFromBin()
return {};
}

const RzList *cs = rz_bin_object_get_classes(bf->o);
const RzPVector *cs = rz_bin_object_get_classes(bf->o);
if (!cs) {
return {};
}

QList<BinClassDescription> qList;
RzListIter *iter, *iter2, *iter3;
RzBinClass *c;
RzListIter *iter2, *iter3;
RzBinSymbol *sym;
RzBinClassField *f;
CutterRzListForeach (cs, iter, RzBinClass, c) {
for (const auto &c : CutterPVector<RzBinClass>(cs)) {
BinClassDescription classDescription;
classDescription.name = c->name;
classDescription.addr = c->addr;
Expand Down
36 changes: 18 additions & 18 deletions src/widgets/Dashboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Dashboard::updateContents()
int static_value = rz_bin_is_static(core->bin);
setPlainText(ui->staticEdit, tr(setBoolText(static_value)));

RzList *hashes = bf ? rz_bin_file_compute_hashes(core->bin, bf, UT64_MAX) : nullptr;
const RzPVector *hashes = bf ? rz_bin_file_compute_hashes(core->bin, bf, UT64_MAX) : nullptr;

// Delete hashesWidget if it isn't null to avoid duplicate components
if (hashesWidget) {
Expand All @@ -94,23 +94,23 @@ void Dashboard::updateContents()
ui->hashesVerticalLayout->addWidget(hashesWidget);

// Add hashes as a pair of Hash Name : Hash Value.
RzListIter *iter;
RzBinFileHash *hash;
CutterRzListForeach (hashes, iter, RzBinFileHash, hash) {
// Create a bold QString with the hash name uppercased
QString label = QString("<b>%1:</b>").arg(QString(hash->type).toUpper());

// Define a Read-Only line edit to display the hash value
QLineEdit *hashLineEdit = new QLineEdit();
hashLineEdit->setReadOnly(true);
hashLineEdit->setText(hash->hex);

// Set cursor position to begining to avoid long hashes (e.g sha256)
// to look truncated at the begining
hashLineEdit->setCursorPosition(0);

// Add both controls to a form layout in a single row
hashesLayout->addRow(new QLabel(label), hashLineEdit);
if (hashes != nullptr) {
for (const auto &hash : CutterPVector<RzBinFileHash>(hashes)) {
// Create a bold QString with the hash name uppercased
QString label = QString("<b>%1:</b>").arg(QString(hash->type).toUpper());

// Define a Read-Only line edit to display the hash value
QLineEdit *hashLineEdit = new QLineEdit();
hashLineEdit->setReadOnly(true);
hashLineEdit->setText(hash->hex);

// Set cursor position to begining to avoid long hashes (e.g sha256)
// to look truncated at the begining
hashLineEdit->setCursorPosition(0);

// Add both controls to a form layout in a single row
hashesLayout->addRow(new QLabel(label), hashLineEdit);
}
}

st64 fcns = rz_list_length(core->analysis->fcns);
Expand Down

0 comments on commit d232542

Please sign in to comment.