diff options
author | Gregor Beck <gbeck@sernet.de> | 2013-01-10 11:09:09 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-02-19 12:10:24 +0100 |
commit | d8dd0ecc484ccc0c3450c3e96725e56e8bf1a9ef (patch) | |
tree | 9bb3965cd637c25c020d79c2a766add45d606103 /source3 | |
parent | d23f19ab00314d773edb07a45e754365db378668 (diff) | |
download | samba-d8dd0ecc484ccc0c3450c3e96725e56e8bf1a9ef.tar.gz samba-d8dd0ecc484ccc0c3450c3e96725e56e8bf1a9ef.tar.bz2 samba-d8dd0ecc484ccc0c3450c3e96725e56e8bf1a9ef.zip |
lib/util_tdb: factor out tdb_data_talloc_copy()
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/utils/net_idmap_check.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c index 4174238298..e75c8906de 100644 --- a/source3/utils/net_idmap_check.c +++ b/source3/utils/net_idmap_check.c @@ -42,7 +42,6 @@ static int traverse_check(struct db_record *rec, void* data); /* TDB_DATA *******************************************************************/ static char* print_data(TALLOC_CTX* mem_ctx, TDB_DATA d); static TDB_DATA parse_data(TALLOC_CTX* mem_ctx, const char** ptr); -static TDB_DATA talloc_copy(TALLOC_CTX* mem_ctx, TDB_DATA data); /* record *********************************************************************/ @@ -325,7 +324,7 @@ static int add_record(struct check_ctx* ctx, TDB_DATA key, TDB_DATA value) diff = unpack_diff(recvalue); talloc_free(diff.nval.dptr); } - diff.nval = talloc_copy(ctx->diff, value); + diff.nval = tdb_data_talloc_copy(ctx->diff, value); DEBUG_DIFF(2, mem, "TDB DIFF", key, diff.oval, diff.nval); @@ -355,7 +354,7 @@ fetch_record(struct check_ctx* ctx, TALLOC_CTX* mem_ctx, TDB_DATA key) if (NT_STATUS_IS_OK(status)) { TDB_DATA_diff diff = unpack_diff(tmp); - TDB_DATA ret = talloc_copy(mem_ctx, diff.nval); + TDB_DATA ret = tdb_data_talloc_copy(mem_ctx, diff.nval); talloc_free(tmp.dptr); return ret; } @@ -548,20 +547,6 @@ void adjust_hwm(struct check_ctx* ctx, const struct record* r) { } } -TDB_DATA talloc_copy(TALLOC_CTX* mem_ctx, TDB_DATA data) { - TDB_DATA ret = { - .dptr = (uint8_t *)talloc_size(mem_ctx, data.dsize+1), - .dsize = data.dsize - }; - if (ret.dptr == NULL) { - ret.dsize = 0; - } else { - memcpy(ret.dptr, data.dptr, data.dsize); - ret.dptr[ret.dsize] = '\0'; - } - return ret; -} - static bool is_cstr(TDB_DATA str) { return !tdb_data_is_empty(str) && str.dptr[str.dsize-1] == '\0'; } @@ -603,8 +588,8 @@ parse_record(TALLOC_CTX* mem_ctx, TDB_DATA key, TDB_DATA val) DEBUG(0, ("Out of memory.\n")); return NULL; } - ret->key = talloc_copy(ret, key); - ret->val = talloc_copy(ret, val); + ret->key = tdb_data_talloc_copy(ret, key); + ret->val = tdb_data_talloc_copy(ret, val); if ((ret->key.dptr == NULL && key.dptr != NULL) || (ret->val.dptr == NULL && val.dptr != NULL)) { |