From 77dca703504044412872b7e9ad4d2c9c1971ba32 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 8 Dec 2011 16:37:40 +0100 Subject: s3-dbwrap: Rewrite dbwrap_fallback_parse_record based on dbwrap_fetch_locked This is in preparation to remove the db_context->fetch function pointer Signed-off-by: Michael Adam --- source3/lib/dbwrap/dbwrap.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c index 8ad6c946e9..0635d76b2c 100644 --- a/source3/lib/dbwrap/dbwrap.c +++ b/source3/lib/dbwrap/dbwrap.c @@ -65,14 +65,23 @@ static NTSTATUS dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key void *private_data), void *private_data) { + struct db_record *rec; TDB_DATA data; - NTSTATUS status; - status = dbwrap_fetch(db, talloc_tos(), key, &data); - if (!NT_STATUS_IS_OK(status)) { - return status; + rec = dbwrap_fetch_locked(db, talloc_tos(), key); + if (rec == NULL) { + return NT_STATUS_NOT_FOUND; + } + data = dbwrap_record_get_value(rec); + + data.dptr = talloc_memdup(talloc_tos(), data.dptr, data.dsize); + TALLOC_FREE(rec); + if (data.dptr == NULL) { + return NT_STATUS_NO_MEMORY; } + parser(key, data, private_data); + TALLOC_FREE(data.dptr); return NT_STATUS_OK; } -- cgit