From 2fb8589862506d8a325f85c6c7d67509fe149d48 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Sep 2006 07:15:42 +0000 Subject: r18709: add some useful function from samba4 metze (This used to be commit f7a93b6acb705256c2aa4fe6475b89223af30491) --- source3/lib/data_blob.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source3/lib/data_blob.c b/source3/lib/data_blob.c index 4d5dda2435..c7eadc1acf 100644 --- a/source3/lib/data_blob.c +++ b/source3/lib/data_blob.c @@ -118,3 +118,28 @@ void data_blob_clear_free(DATA_BLOB *d) data_blob_clear(d); data_blob_free(d); } + +/** + useful for constructing data blobs in test suites, while + avoiding const warnings +**/ +DATA_BLOB data_blob_string_const(const char *str) +{ + DATA_BLOB blob; + blob.data = CONST_DISCARD(uint8 *, str); + blob.length = strlen(str); + blob.free = NULL; + return blob; +} + +/** + * Create a new data blob from const data + */ +DATA_BLOB data_blob_const(const void *p, size_t length) +{ + DATA_BLOB blob; + blob.data = CONST_DISCARD(uint8 *, p); + blob.length = length; + blob.free = NULL; + return blob; +} -- cgit