From 83391396b9361776e3ec06270aa39b64c0a9b17a Mon Sep 17 00:00:00 2001 From: Dhruv Maroo Date: Wed, 20 Sep 2023 07:36:38 +0530 Subject: [PATCH] Start using `RzPVector` and `CutterPVector` instead of `RzList` --- src/core/Cutter.cpp | 11 +++++------ src/widgets/Dashboard.cpp | 30 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index edd78682..b70b1585 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -3109,14 +3109,14 @@ QList CutterCore::getAllImports() if (!bf) { return {}; } - const auto *imports = new CutterPVector(rz_bin_object_get_imports(bf->o)); + const RzPVector *imports = rz_bin_object_get_imports(bf->o); if (!imports) { return {}; } QList qList; bool va = core->io->va || core->bin->is_debugger; - for (auto import : *imports) { + for (const auto &import : CutterPVector(imports)) { if (RZ_STR_ISEMPTY(import->name)) { continue; } @@ -3557,17 +3557,16 @@ QList 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 qList; - RzListIter *iter, *iter2, *iter3; - RzBinClass *c; + RzListIter *iter2, *iter3; RzBinSymbol *sym; RzBinClassField *f; - CutterRzListForeach (cs, iter, RzBinClass, c) { + for (const auto &c : CutterPVector(cs)) { BinClassDescription classDescription; classDescription.name = c->name; classDescription.addr = c->addr; diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp index 3636492b..aeb156c3 100644 --- a/src/widgets/Dashboard.cpp +++ b/src/widgets/Dashboard.cpp @@ -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) { @@ -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("%1:").arg(QString(hash->type).toUpper()); + if (hashes != nullptr) { + for (const auto &hash : CutterPVector(hashes)) { + // Create a bold QString with the hash name uppercased + QString label = QString("%1:").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); + // 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); + // 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); + // 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);