diff options
author | Volker Lendecke <vl@samba.org> | 2009-08-08 13:43:41 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-08-08 13:44:31 +0200 |
commit | 1de9805fa3d5f05d187df092a65955dfc62a3d81 (patch) | |
tree | 697aa97c3838fc17e52c5b8266c8da475d1586ec | |
parent | e8088e16f812d682e08ad558865d0cc6eab2ad9c (diff) | |
download | samba-1de9805fa3d5f05d187df092a65955dfc62a3d81.tar.gz samba-1de9805fa3d5f05d187df092a65955dfc62a3d81.tar.bz2 samba-1de9805fa3d5f05d187df092a65955dfc62a3d81.zip |
Implement db_rbt_traverse
-rw-r--r-- | source3/lib/dbwrap_rbt.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/source3/lib/dbwrap_rbt.c b/source3/lib/dbwrap_rbt.c index cf4faa25b9..e9b0e4616f 100644 --- a/source3/lib/dbwrap_rbt.c +++ b/source3/lib/dbwrap_rbt.c @@ -335,16 +335,45 @@ static int db_rbt_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, return 0; } +static int db_rbt_traverse_internal(struct rb_node *n, + int (*f)(struct db_record *db, + void *private_data), + void *private_data) +{ + struct db_rbt_node *r; + struct db_record rec; + int ret; + + if (n == NULL) { + return 0; + } + + ret = db_rbt_traverse_internal(n->rb_left, f, private_data); + if (ret != 0) { + return ret; + } + + r = db_rbt2node(n); + ZERO_STRUCT(rec); + db_rbt_parse_node(r, &rec.key, &rec.value); + + ret = f(&rec, private_data); + if (ret != 0) { + return ret; + } + + return db_rbt_traverse_internal(n->rb_right, f, private_data); +} static int db_rbt_traverse(struct db_context *db, int (*f)(struct db_record *db, void *private_data), void *private_data) { - /* - * Nobody uses this so far, and unused code is broken code :-) - */ - return -1; + struct db_rbt_ctx *ctx = talloc_get_type_abort( + db->private_data, struct db_rbt_ctx); + + return db_rbt_traverse_internal(ctx->tree.rb_node, f, private_data); } static int db_rbt_get_seqnum(struct db_context *db) |