Skip to content

Commit

Permalink
Remove SdbList (#4496)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelijah authored May 17, 2024
1 parent 7a767f2 commit 9c34738
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 1,047 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ AlignConsecutiveMacros: true
AlignTrailingComments: false
AlignOperands: false
Cpp11BracedListStyle: false
ForEachMacros: ['rz_list_foreach', 'rz_list_foreach_safe', 'rz_vector_foreach', 'rz_vector_foreach_prev', 'rz_vector_enumerate', 'rz_pvector_foreach', 'rz_pvector_enumerate', 'rz_rbtree_foreach', 'rz_interval_tree_foreach', 'ls_foreach', 'rz_skiplist_foreach', 'graph_foreach_anode']
ForEachMacros: ['rz_list_foreach', 'rz_list_foreach_safe', 'rz_vector_foreach', 'rz_vector_foreach_prev', 'rz_vector_enumerate', 'rz_pvector_foreach', 'rz_pvector_enumerate', 'rz_rbtree_foreach', 'rz_interval_tree_foreach', 'rz_skiplist_foreach', 'graph_foreach_anode']
SortIncludes: false
RequiresClausePosition: SingleLine
TypenameMacros: ['HT_', 'Ht_', 'HtName_']
6 changes: 3 additions & 3 deletions librz/core/cmd/cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -2455,7 +2455,7 @@ static void do_string_search(RzCore *core, RzInterval search_itv, struct search_
static void rop_kuery(void *data, const char *input, PJ *pj) {
RzCore *core = (RzCore *)data;
Sdb *db_rop = sdb_ns(core->sdb, "rop", false);
SdbListIter *it;
RzListIter *it;
void **items_iter;
SdbNs *ns;
char *out;
Expand All @@ -2467,7 +2467,7 @@ static void rop_kuery(void *data, const char *input, PJ *pj) {

switch (*input) {
case 'q':
ls_foreach (db_rop->ns, it, ns) {
rz_list_foreach (db_rop->ns, it, ns) {
RzPVector *items = sdb_get_items(ns->sdb, false);
rz_pvector_foreach (items, items_iter) {
SdbKv *kv = *items_iter;
Expand All @@ -2479,7 +2479,7 @@ static void rop_kuery(void *data, const char *input, PJ *pj) {
case 'j':
pj_o(pj);
pj_ka(pj, "gadgets");
ls_foreach (db_rop->ns, it, ns) {
rz_list_foreach (db_rop->ns, it, ns) {
RzPVector *items = sdb_get_items(ns->sdb, false);
rz_pvector_foreach (items, items_iter) {
SdbKv *kv = *items_iter;
Expand Down
4 changes: 2 additions & 2 deletions librz/debug/dsession.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ static bool session_sdb_save(Sdb *db, const char *path) {
free(filename);
sdb_close(db);

SdbListIter *it;
RzListIter *it;
SdbNs *ns;
ls_foreach (db->ns, it, ns) {
rz_list_foreach (db->ns, it, ns) {
char *filename = rz_str_newf("%s%s%s.sdb", path, RZ_SYS_DIR, ns->name);
sdb_file(ns->sdb, filename);
if (!sdb_sync(ns->sdb)) {
Expand Down
36 changes: 18 additions & 18 deletions librz/util/sdb/src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ RZ_API int sdb_diff_format(char *str, int size, const SdbDiff *diff) {

APPENDF("%c%s ", diff->add ? '+' : '-', diff->v ? " " : "NS");

SdbListIter *it;
RzListIter *it;
const char *component;
ls_foreach (diff->path, it, component) {
rz_list_foreach (diff->path, it, component) {
APPENDF("%s/", component);
}

Expand All @@ -45,7 +45,7 @@ typedef struct sdb_diff_ctx_t {
Sdb *b;
bool equal;
VALUE_EQ_F eq;
SdbList *path;
RzList /*<char *>*/ *path;
SdbDiffCallback cb;
void *cb_user;
} SdbDiffCtx;
Expand Down Expand Up @@ -86,13 +86,13 @@ static bool sdb_diff_report_kv_cb(void *user, const SdbKv *kv) {
* just report everything from sdb to buf with prefix
*/
static void sdb_diff_report(SdbDiffCtx *ctx, Sdb *sdb, bool add) {
SdbListIter *it;
RzListIter *it;
SdbNs *ns;
ls_foreach (sdb->ns, it, ns) {
rz_list_foreach (sdb->ns, it, ns) {
sdb_diff_report_ns(ctx, ns, add);
ls_push(ctx->path, ns->name);
rz_list_append(ctx->path, ns->name);
sdb_diff_report(ctx, ns->sdb, add);
ls_pop(ctx->path);
rz_list_pop(ctx->path);
}
SdbDiffKVCbCtx cb_ctx = { ctx, add };
sdb_foreach(sdb, sdb_diff_report_kv_cb, &cb_ctx);
Expand All @@ -119,36 +119,36 @@ static bool sdb_diff_kv_cb(void *user, const SdbKv *kv) {
}

static void sdb_diff_ctx(SdbDiffCtx *ctx) {
SdbListIter *it;
RzListIter *it;
SdbNs *ns;
ls_foreach (ctx->a->ns, it, ns) {
rz_list_foreach (ctx->a->ns, it, ns) {
Sdb *b_ns = sdb_ns(ctx->b, ns->name, false);
if (!b_ns) {
DIFF(ctx,
sdb_diff_report_ns(ctx, ns, false);
ls_push(ctx->path, ns->name);
rz_list_append(ctx->path, ns->name);
sdb_diff_report(ctx, ns->sdb, false);
ls_pop(ctx->path);
rz_list_pop(ctx->path);
, );
continue;
}
Sdb *a = ctx->a;
Sdb *b = ctx->b;
ctx->a = ns->sdb;
ctx->b = b_ns;
ls_push(ctx->path, ns->name);
rz_list_append(ctx->path, ns->name);
sdb_diff_ctx(ctx);
ls_pop(ctx->path);
rz_list_pop(ctx->path);
ctx->a = a;
ctx->b = b;
}
ls_foreach (ctx->b->ns, it, ns) {
rz_list_foreach (ctx->b->ns, it, ns) {
if (!sdb_ns(ctx->a, ns->name, false)) {
DIFF(ctx,
sdb_diff_report_ns(ctx, ns, true);
ls_push(ctx->path, ns->name);
rz_list_append(ctx->path, ns->name);
sdb_diff_report(ctx, ns->sdb, true);
ls_pop(ctx->path);
rz_list_pop(ctx->path);
, );
}
}
Expand All @@ -172,11 +172,11 @@ RZ_API bool sdb_diff_eq(Sdb *a, Sdb *b, VALUE_EQ_F eq, SdbDiffCallback cb, void
ctx.eq = eq;
ctx.cb = cb;
ctx.cb_user = cb_user;
ctx.path = ls_new();
ctx.path = rz_list_new();
if (!ctx.path) {
return false;
}
sdb_diff_ctx(&ctx);
ls_free(ctx.path);
rz_list_free(ctx.path);
return ctx.equal;
}
Loading

0 comments on commit 9c34738

Please sign in to comment.