summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-11-10 14:46:10 +0100
committerMichael Adam <obnox@samba.org>2012-11-29 17:55:19 +0100
commita742b6edd5dc23378ec1926777af67ad54e75e10 (patch)
treecbae179d7e85ab3bc885fd7b6675f246afb41cba /source3/lib
parent664b170b13674c26c94ec1d3603570e707f8f1e5 (diff)
downloadsamba-a742b6edd5dc23378ec1926777af67ad54e75e10.tar.gz
samba-a742b6edd5dc23378ec1926777af67ad54e75e10.tar.bz2
samba-a742b6edd5dc23378ec1926777af67ad54e75e10.zip
s3: Factor out db_ctdb_marshall_loop_next_key from db_ctdb_marshall_loop_next
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap/dbwrap_ctdb.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 43b4b28d0d..dea3dc281c 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -324,24 +324,40 @@ static TDB_DATA db_ctdb_marshall_finish(struct ctdb_marshall_buffer *m)
- pass r==NULL to start
- loop the number of times indicated by m->count
*/
+static struct ctdb_rec_data *db_ctdb_marshall_loop_next_key(
+ struct ctdb_marshall_buffer *m, struct ctdb_rec_data *r, TDB_DATA *key)
+{
+ if (r == NULL) {
+ r = (struct ctdb_rec_data *)&m->data[0];
+ } else {
+ r = (struct ctdb_rec_data *)(r->length + (uint8_t *)r);
+ }
+
+ key->dptr = &r->data[0];
+ key->dsize = r->keylen;
+ return r;
+}
+
+/*
+ loop over a marshalling buffer
+
+ - pass r==NULL to start
+ - loop the number of times indicated by m->count
+*/
static struct ctdb_rec_data *db_ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, struct ctdb_rec_data *r,
uint32_t *reqid,
struct ctdb_ltdb_header *header,
TDB_DATA *key, TDB_DATA *data)
{
+ r = db_ctdb_marshall_loop_next_key(m, r, key);
if (r == NULL) {
- r = (struct ctdb_rec_data *)&m->data[0];
- } else {
- r = (struct ctdb_rec_data *)(r->length + (uint8_t *)r);
+ return NULL;
}
if (reqid != NULL) {
*reqid = r->reqid;
}
- key->dptr = &r->data[0];
- key->dsize = r->keylen;
-
if (data != NULL) {
data->dptr = &r->data[r->keylen];
data->dsize = r->datalen;
@@ -1438,9 +1454,8 @@ static int db_ctdb_traverse(struct db_context *db,
for (i=0; i<mbuf->count; i++) {
TDB_DATA key;
- rec =db_ctdb_marshall_loop_next(mbuf, rec,
- NULL, NULL,
- &key, NULL);
+ rec = db_ctdb_marshall_loop_next_key(
+ mbuf, rec, &key);
SMB_ASSERT(rec != NULL);
if (!tdb_exists(ltdb, key)) {