diff options
author | Volker Lendecke <vl@samba.org> | 2009-07-13 17:03:52 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-07-15 10:55:20 +0200 |
commit | ed87594e5fd3251f9cb3beaca06c8eee1dcd4ed2 (patch) | |
tree | 8ec53a266e1d5a7e5d401061841be1d24c044921 /source3/lib | |
parent | 3edcd55bf140d09833284ba5a0f04f86b04ef7dc (diff) | |
download | samba-ed87594e5fd3251f9cb3beaca06c8eee1dcd4ed2.tar.gz samba-ed87594e5fd3251f9cb3beaca06c8eee1dcd4ed2.tar.bz2 samba-ed87594e5fd3251f9cb3beaca06c8eee1dcd4ed2.zip |
Add tdb_data_cmp
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_tdb.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index 78fa7cd0a1..5b3d94dabe 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -630,3 +630,22 @@ NTSTATUS map_nt_error_from_tdb(enum TDB_ERROR err) return NT_STATUS_INTERNAL_ERROR; } + +int tdb_data_cmp(TDB_DATA t1, TDB_DATA t2) +{ + int ret; + if (t1.dptr == NULL && t2.dptr != NULL) { + return -1; + } + if (t1.dptr != NULL && t2.dptr == NULL) { + return 1; + } + if (t1.dptr == t2.dptr) { + return t1.dsize - t2.dsize; + } + ret = memcmp(t1.dptr, t2.dptr, MIN(t1.dsize, t2.dsize)); + if (ret == 0) { + return t1.dsize - t2.dsize; + } + return ret; +} |