diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/talloc_dict.c | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/source3/lib/talloc_dict.c b/source3/lib/talloc_dict.c index b7d4fe0dab..71ab899006 100644 --- a/source3/lib/talloc_dict.c +++ b/source3/lib/talloc_dict.c @@ -56,29 +56,34 @@ bool talloc_dict_set(struct talloc_dict *dict, DATA_BLOB key, void *pdata) struct db_record *rec; NTSTATUS status = NT_STATUS_OK; void *data = *(void **)pdata; + TDB_DATA value; - rec = dict->db->fetch_locked(dict->db, talloc_tos(), - make_tdb_data(key.data, key.length)); + rec = dbwrap_fetch_locked(dict->db, talloc_tos(), + make_tdb_data(key.data, key.length)); if (rec == NULL) { return false; } - if (rec->value.dsize != 0) { + + value = dbwrap_record_get_value(rec); + + if (value.dsize != 0) { void *old_data; - if (rec->value.dsize != sizeof(void *)) { + if (value.dsize != sizeof(void *)) { TALLOC_FREE(rec); return false; } - old_data = *(void **)(rec->value.dptr); + old_data = *(void **)(value.dptr); TALLOC_FREE(old_data); if (data == NULL) { - status = rec->delete_rec(rec); + status = dbwrap_record_delete(rec); } } if (data != NULL) { void *mydata = talloc_move(dict->db, &data); *(void **)pdata = NULL; - status = rec->store(rec, make_tdb_data((uint8_t *)&mydata, - sizeof(mydata)), 0); + status = dbwrap_record_store(rec, + make_tdb_data((uint8_t *)&mydata, + sizeof(mydata)), 0); } TALLOC_FREE(rec); return NT_STATUS_IS_OK(status); @@ -94,21 +99,24 @@ void *talloc_dict_fetch(struct talloc_dict *dict, DATA_BLOB key, { struct db_record *rec; void *result; + TDB_DATA value; - rec = dict->db->fetch_locked(dict->db, talloc_tos(), - make_tdb_data(key.data, key.length)); + rec = dbwrap_fetch_locked(dict->db, talloc_tos(), + make_tdb_data(key.data, key.length)); if (rec == NULL) { return NULL; } - if (rec->value.dsize != sizeof(void *)) { + + value = dbwrap_record_get_value(rec); + if (value.dsize != sizeof(void *)) { TALLOC_FREE(rec); return NULL; } - result = *(void **)rec->value.dptr; + result = *(void **)value.dptr; if (mem_ctx != NULL) { NTSTATUS status; - status = rec->delete_rec(rec); + status = dbwrap_record_delete(rec); if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(rec); return NULL; @@ -126,14 +134,19 @@ struct talloc_dict_traverse_state { static int talloc_dict_traverse_fn(struct db_record *rec, void *private_data) { + TDB_DATA key; + TDB_DATA value; struct talloc_dict_traverse_state *state = (struct talloc_dict_traverse_state *)private_data; - if (rec->value.dsize != sizeof(void *)) { + key = dbwrap_record_get_key(rec); + value = dbwrap_record_get_value(rec); + + if (value.dsize != sizeof(void *)) { return -1; } - return state->fn(data_blob_const(rec->key.dptr, rec->key.dsize), - *(void **)rec->value.dptr, state->private_data); + return state->fn(data_blob_const(key.dptr, key.dsize), + *(void **)value.dptr, state->private_data); } /* @@ -146,7 +159,16 @@ int talloc_dict_traverse(struct talloc_dict *dict, void *private_data) { struct talloc_dict_traverse_state state; + NTSTATUS status; + int count = 0; + state.fn = fn; state.private_data = private_data; - return dict->db->traverse(dict->db, talloc_dict_traverse_fn, &state); + status = dbwrap_traverse(dict->db, talloc_dict_traverse_fn, &state, + &count); + if (!NT_STATUS_IS_OK(status)) { + return -1; + } else { + return count; + } } |