summaryrefslogtreecommitdiffstats
path: root/source4/lib/util/data_blob.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-06-20 04:15:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:53:26 -0500
commitd291b8bf933e7595ac2967602d90918c286e3429 (patch)
treed9ba06a19ecdd22052e23856c181fcf5f81c280e /source4/lib/util/data_blob.c
parent576b1c84fb9c5de642b549d769764488436f2c5f (diff)
downloadsamba-d291b8bf933e7595ac2967602d90918c286e3429.tar.gz
samba-d291b8bf933e7595ac2967602d90918c286e3429.tar.xz
samba-d291b8bf933e7595ac2967602d90918c286e3429.zip
r23551: Change data_blob_equal to data_blob_cmp, suitable for sorting with qsort().
Andrew Bartlett (This used to be commit 96ef5259c63ad6245c94c40d6059d736b1534183)
Diffstat (limited to 'source4/lib/util/data_blob.c')
-rw-r--r--source4/lib/util/data_blob.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source4/lib/util/data_blob.c b/source4/lib/util/data_blob.c
index e04bd653318..ca04b70eb22 100644
--- a/source4/lib/util/data_blob.c
+++ b/source4/lib/util/data_blob.c
@@ -130,21 +130,23 @@ _PUBLIC_ void data_blob_clear_free(DATA_BLOB *d)
/**
check if two data blobs are equal
**/
-_PUBLIC_ BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2)
+_PUBLIC_ int data_blob_cmp(const DATA_BLOB *d1, const DATA_BLOB *d2)
{
- if (d1->length != d2->length) {
- return False;
+ int ret;
+ if (d1->data == NULL && d2->data != NULL) {
+ return -1;
}
- if (d1->data == d2->data) {
- return True;
+ if (d1->data != NULL && d2->data == NULL) {
+ return 1;
}
- if (d1->data == NULL || d2->data == NULL) {
- return False;
+ if (d1->data == d2->data) {
+ return d1->length - d2->length;
}
- if (memcmp(d1->data, d2->data, d1->length) == 0) {
- return True;
+ ret = memcmp(d1->data, d2->data, MIN(d1->length, d2->length));
+ if (ret == 0) {
+ return d1->length - d2->length;
}
- return False;
+ return ret;
}
/**