Start using RzPVector and CutterPVector instead of RzList

This commit is contained in:
Dhruv Maroo 2023-09-20 07:36:38 +05:30 committed by Anton Kochkov
parent 3c682b0458
commit 83391396b9
2 changed files with 20 additions and 21 deletions

View File

@ -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;
}
@ -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;

View File

@ -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("<b>%1:</b>").arg(QString(hash->type).toUpper());
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);
// 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);