diff --git a/rizin b/rizin index 34f1a9e7..a02e6080 160000 --- a/rizin +++ b/rizin @@ -1 +1 @@ -Subproject commit 34f1a9e7b40e289cdf8e7f03c145bdbd5d41dc89 +Subproject commit a02e608075986bbb8d55c643c698f235a643e56c diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index b5271ca7..56253084 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -295,22 +295,25 @@ QList CutterCore::sdbList(QString path) CORE_LOCK(); QList list = QList(); Sdb *root = sdb_ns_path(core->sdb, path.toUtf8().constData(), 0); - if (root) { - void *vsi; - ls_iter_t *iter; - ls_foreach(root->ns, iter, vsi) - { - SdbNs *nsi = (SdbNs *)vsi; + if (root && root->ns) { + for (const auto &nsi : CutterRzList(root->ns)) { list << nsi->name; } } return list; } -using SdbListPtr = std::unique_ptr; -static SdbListPtr makeSdbListPtr(SdbList *list) +using PVectorPtr = std::unique_ptr; +static PVectorPtr makePVectorPtr(RzPVector *vec) { - return { list, ls_free }; + return { vec, rz_pvector_free }; +} + +static bool foreach_keys_cb(void *user, const SdbKv *kv) +{ + auto list = reinterpret_cast *>(user); + *list << kv->base.key; + return true; } QList CutterCore::sdbListKeys(QString path) @@ -319,14 +322,7 @@ QList CutterCore::sdbListKeys(QString path) QList list = QList(); Sdb *root = sdb_ns_path(core->sdb, path.toUtf8().constData(), 0); if (root) { - void *vsi; - ls_iter_t *iter; - SdbListPtr l = makeSdbListPtr(sdb_foreach_list(root, false)); - ls_foreach(l, iter, vsi) - { - SdbKv *nsi = (SdbKv *)vsi; - list << reinterpret_cast(nsi->base.key); - } + sdb_foreach(root, foreach_keys_cb, &list); } return list; } @@ -336,7 +332,7 @@ QString CutterCore::sdbGet(QString path, QString key) CORE_LOCK(); Sdb *db = sdb_ns_path(core->sdb, path.toUtf8().constData(), 0); if (db) { - const char *val = sdb_const_get(db, key.toUtf8().constData(), 0); + const char *val = sdb_const_get(db, key.toUtf8().constData()); if (val && *val) return val; } @@ -349,7 +345,7 @@ bool CutterCore::sdbSet(QString path, QString key, QString val) Sdb *db = sdb_ns_path(core->sdb, path.toUtf8().constData(), 1); if (!db) return false; - return sdb_set(db, key.toUtf8().constData(), val.toUtf8().constData(), 0); + return sdb_set(db, key.toUtf8().constData(), val.toUtf8().constData()); } QString CutterCore::sanitizeStringForCommand(QString s) @@ -3616,21 +3612,14 @@ QList CutterCore::getAllAnalysisClasses(bool sorted) { CORE_LOCK(); QList ret; - - SdbListPtr l = makeSdbListPtr(rz_analysis_class_get_all(core->analysis, sorted)); + PVectorPtr l = makePVectorPtr(rz_analysis_class_get_all(core->analysis, sorted)); if (!l) { return ret; } - ret.reserve(static_cast(l->length)); - - SdbListIter *it; - void *entry; - ls_foreach(l, it, entry) - { - auto kv = reinterpret_cast(entry); + ret.reserve(static_cast(rz_pvector_len(l.get()))); + for (const auto &kv : CutterPVector(l.get())) { ret.append(QString::fromUtf8(reinterpret_cast(kv->base.key))); } - return ret; } @@ -4371,13 +4360,14 @@ QStringList CutterCore::getColorThemes() { QStringList r; CORE_LOCK(); - RzList *themes_list = rz_core_theme_list(core); - RzListIter *it; - const char *th; - CutterRzListForeach (themes_list, it, const char, th) { + RzPVector *themes_list = rz_core_get_themes(core); + if (!themes_list) { + return r; + } + for (const auto &th : CutterPVector(themes_list)) { r << fromOwnedCharPtr(rz_str_trim_dup(th)); } - rz_list_free(themes_list); + rz_pvector_free(themes_list); return r; } diff --git a/src/dialogs/VersionInfoDialog.cpp b/src/dialogs/VersionInfoDialog.cpp index 9cd5e03c..f156387e 100644 --- a/src/dialogs/VersionInfoDialog.cpp +++ b/src/dialogs/VersionInfoDialog.cpp @@ -46,20 +46,20 @@ void VersionInfoDialog::fillVersionInfo() // Left tree QTreeWidgetItem *addrItemL = new QTreeWidgetItem(); addrItemL->setText(0, "Address:"); - addrItemL->setText(1, RzAddressString(sdb_num_get(sdb, "addr", 0))); + addrItemL->setText(1, RzAddressString(sdb_num_get(sdb, "addr"))); ui->leftTreeWidget->addTopLevelItem(addrItemL); QTreeWidgetItem *offItemL = new QTreeWidgetItem(); offItemL->setText(0, "Offset:"); - offItemL->setText(1, RzAddressString(sdb_num_get(sdb, "offset", 0))); + offItemL->setText(1, RzAddressString(sdb_num_get(sdb, "offset"))); ui->leftTreeWidget->addTopLevelItem(offItemL); QTreeWidgetItem *entriesItemL = new QTreeWidgetItem(); entriesItemL->setText(0, "Entries:"); - const ut64 num_entries = sdb_num_get(sdb, "num_entries", 0); + const ut64 num_entries = sdb_num_get(sdb, "num_entries"); for (size_t i = 0; i < num_entries; ++i) { auto key = QString("entry%0").arg(i); - const char *const value = sdb_const_get(sdb, key.toStdString().c_str(), 0); + const char *const value = sdb_const_get(sdb, key.toStdString().c_str()); if (!value) { continue; } @@ -77,12 +77,12 @@ void VersionInfoDialog::fillVersionInfo() // Right tree QTreeWidgetItem *addrItemR = new QTreeWidgetItem(); addrItemR->setText(0, "Address:"); - addrItemR->setText(1, RzAddressString(sdb_num_get(sdb, "addr", 0))); + addrItemR->setText(1, RzAddressString(sdb_num_get(sdb, "addr"))); ui->rightTreeWidget->addTopLevelItem(addrItemR); QTreeWidgetItem *offItemR = new QTreeWidgetItem(); offItemR->setText(0, "Offset:"); - offItemR->setText(1, RzAddressString(sdb_num_get(sdb, "offset", 0))); + offItemR->setText(1, RzAddressString(sdb_num_get(sdb, "offset"))); ui->rightTreeWidget->addTopLevelItem(offItemR); QTreeWidgetItem *entriesItemR = new QTreeWidgetItem(); @@ -94,13 +94,13 @@ void VersionInfoDialog::fillVersionInfo() if (!sdb) { break; } - const char *filename = sdb_const_get(sdb, "file_name", 0); + const char *filename = sdb_const_get(sdb, "file_name"); auto *parentItem = new QTreeWidgetItem(); - parentItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx", 0))); + parentItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx"))); parentItem->setText(1, QString("Version: %0\t" "File: %1") - .arg(QString::number(sdb_num_get(sdb, "vn_version", 0)), + .arg(QString::number(sdb_num_get(sdb, "vn_version")), QString(filename))); int num_vernaux = 0; @@ -113,13 +113,13 @@ void VersionInfoDialog::fillVersionInfo() } auto *childItem = new QTreeWidgetItem(); - childItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx", 0))); + childItem->setText(0, RzAddressString(sdb_num_get(sdb, "idx"))); QString childString = QString("Name: %0\t" "Flags: %1\t" "Version: %2\t") - .arg(sdb_const_get(sdb, "name", 0), sdb_const_get(sdb, "flags", 0), - QString::number(sdb_num_get(sdb, "version", 0))); + .arg(sdb_const_get(sdb, "name"), sdb_const_get(sdb, "flags"), + QString::number(sdb_num_get(sdb, "version"))); childItem->setText(1, childString); parentItem->addChild(childItem); } @@ -144,15 +144,15 @@ void VersionInfoDialog::fillVersionInfo() if (!sdb) { return; } - ut32 file_version_ms = sdb_num_get(sdb, "FileVersionMS", 0); - ut32 file_version_ls = sdb_num_get(sdb, "FileVersionLS", 0); + ut32 file_version_ms = sdb_num_get(sdb, "FileVersionMS"); + ut32 file_version_ls = sdb_num_get(sdb, "FileVersionLS"); auto file_version = QString("%0.%1.%2.%3") .arg(file_version_ms >> 16) .arg(file_version_ms & 0xFFFF) .arg(file_version_ls >> 16) .arg(file_version_ls & 0xFFFF); - ut32 product_version_ms = sdb_num_get(sdb, "ProductVersionMS", 0); - ut32 product_version_ls = sdb_num_get(sdb, "ProductVersionLS", 0); + ut32 product_version_ms = sdb_num_get(sdb, "ProductVersionMS"); + ut32 product_version_ls = sdb_num_get(sdb, "ProductVersionLS"); auto product_version = QString("%0.%1.%2.%3") .arg(product_version_ms >> 16) .arg(product_version_ms & 0xFFFF) @@ -161,12 +161,12 @@ void VersionInfoDialog::fillVersionInfo() auto item = new QTreeWidgetItem(); item->setText(0, "Signature"); - item->setText(1, RzHexString(sdb_num_get(sdb, "Signature", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "Signature"))); ui->leftTreeWidget->addTopLevelItem(item); item = new QTreeWidgetItem(); item->setText(0, "StrucVersion"); - item->setText(1, RzHexString(sdb_num_get(sdb, "StrucVersion", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "StrucVersion"))); ui->leftTreeWidget->addTopLevelItem(item); item = new QTreeWidgetItem(); @@ -181,27 +181,27 @@ void VersionInfoDialog::fillVersionInfo() item = new QTreeWidgetItem(); item->setText(0, "FileFlagsMask"); - item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlagsMask", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlagsMask"))); ui->leftTreeWidget->addTopLevelItem(item); item = new QTreeWidgetItem(); item->setText(0, "FileFlags"); - item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlags", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "FileFlags"))); ui->leftTreeWidget->addTopLevelItem(item); item = new QTreeWidgetItem(); item->setText(0, "FileOS"); - item->setText(1, RzHexString(sdb_num_get(sdb, "FileOS", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "FileOS"))); ui->leftTreeWidget->addTopLevelItem(item); item = new QTreeWidgetItem(); item->setText(0, "FileType"); - item->setText(1, RzHexString(sdb_num_get(sdb, "FileType", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "FileType"))); ui->leftTreeWidget->addTopLevelItem(item); item = new QTreeWidgetItem(); item->setText(0, "FileSubType"); - item->setText(1, RzHexString(sdb_num_get(sdb, "FileSubType", 0))); + item->setText(1, RzHexString(sdb_num_get(sdb, "FileSubType"))); ui->leftTreeWidget->addTopLevelItem(item); // Adjust columns to content @@ -224,8 +224,8 @@ void VersionInfoDialog::fillVersionInfo() } int lenkey = 0; int lenval = 0; - ut8 *key_utf16 = sdb_decode(sdb_const_get(sdb, "key", 0), &lenkey); - ut8 *val_utf16 = sdb_decode(sdb_const_get(sdb, "value", 0), &lenval); + ut8 *key_utf16 = sdb_decode(sdb_const_get(sdb, "key"), &lenkey); + ut8 *val_utf16 = sdb_decode(sdb_const_get(sdb, "value"), &lenval); item = new QTreeWidgetItem(); item->setText(0, QString::fromUtf16(reinterpret_cast(key_utf16))); item->setText(1, QString::fromUtf16(reinterpret_cast(val_utf16))); diff --git a/src/tools/basefind/BaseFindDialog.cpp b/src/tools/basefind/BaseFindDialog.cpp index 17adc133..bcd77756 100644 --- a/src/tools/basefind/BaseFindDialog.cpp +++ b/src/tools/basefind/BaseFindDialog.cpp @@ -12,7 +12,7 @@ BaseFindDialog::BaseFindDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Ba setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); // Fill in N-thread Combo - size_t n_cores = rz_th_physical_core_number(); + RzThreadNCores n_cores = rz_th_physical_core_number(); ui->nCoresCombo->clear(); for (size_t i = n_cores; i > 0; i--) { if (n_cores == i) { @@ -36,10 +36,10 @@ BaseFindDialog::BaseFindDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Ba BaseFindDialog::~BaseFindDialog() {} -size_t BaseFindDialog::getNCores() const +RzThreadNCores BaseFindDialog::getNCores() const { - size_t n_cores = rz_th_physical_core_number(); - return n_cores - ui->nCoresCombo->currentIndex(); + RzThreadNCores n_cores = rz_th_physical_core_number(); + return static_cast(n_cores - ui->nCoresCombo->currentIndex()); } ut32 BaseFindDialog::getPointerSize() const diff --git a/src/tools/basefind/BaseFindDialog.h b/src/tools/basefind/BaseFindDialog.h index 3142eb88..296b25eb 100644 --- a/src/tools/basefind/BaseFindDialog.h +++ b/src/tools/basefind/BaseFindDialog.h @@ -19,7 +19,7 @@ public: explicit BaseFindDialog(QWidget *parent = nullptr); ~BaseFindDialog(); - size_t getNCores() const; + RzThreadNCores getNCores() const; ut32 getPointerSize() const; RVA getStartAddress() const; RVA getEndAddress() const; diff --git a/src/tools/basefind/BaseFindSearchDialog.cpp b/src/tools/basefind/BaseFindSearchDialog.cpp index bc29af4f..718ec045 100644 --- a/src/tools/basefind/BaseFindSearchDialog.cpp +++ b/src/tools/basefind/BaseFindSearchDialog.cpp @@ -20,7 +20,7 @@ BaseFindSearchDialog::~BaseFindSearchDialog() {} void BaseFindSearchDialog::show(RzBaseFindOpt *opts) { - size_t n_cores = rz_th_physical_core_number(); + RzThreadNCores n_cores = rz_th_physical_core_number(); if (opts->max_threads > n_cores || opts->max_threads < 1) { opts->max_threads = n_cores; } diff --git a/src/widgets/Dashboard.cpp b/src/widgets/Dashboard.cpp index 29a4317f..344dfa8e 100644 --- a/src/widgets/Dashboard.cpp +++ b/src/widgets/Dashboard.cpp @@ -40,7 +40,7 @@ void Dashboard::updateContents() if (bf) { setPlainText(this->ui->compilationDateEdit, rz_core_bin_get_compile_time(bf)); if (bf->o) { - char *relco_buf = sdb_get(bf->o->kv, "elf.relro", 0); + char *relco_buf = sdb_get(bf->o->kv, "elf.relro"); if (RZ_STR_ISNOTEMPTY(relco_buf)) { QString relro = QString(relco_buf).section(QLatin1Char(' '), 0, 0); relro[0] = relro[0].toUpper();