From aa982895e5c13497144740e90ff9646e1d1cf995 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 13 Oct 2008 05:20:26 +0200 Subject: Add data_blob_string_const_null() function that includes the terminating null byte and use it in Samba 3. This matches the behaviour prior to my data_blob changes. --- lib/util/data_blob.c | 12 ++++++++++++ lib/util/data_blob.h | 8 ++++++++ 2 files changed, 20 insertions(+) (limited to 'lib') diff --git a/lib/util/data_blob.c b/lib/util/data_blob.c index 1b2f05528b..c7d01bacc7 100644 --- a/lib/util/data_blob.c +++ b/lib/util/data_blob.c @@ -182,6 +182,18 @@ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str) return blob; } +/** + useful for constructing data blobs in test suites, while + avoiding const warnings +**/ +_PUBLIC_ DATA_BLOB data_blob_string_const_null(const char *str) +{ + DATA_BLOB blob; + blob.data = discard_const_p(uint8_t, str); + blob.length = str ? strlen(str)+1 : 0; + return blob; +} + /** * Create a new data blob from const data */ diff --git a/lib/util/data_blob.h b/lib/util/data_blob.h index 58c1117f1d..ffde51cf33 100644 --- a/lib/util/data_blob.h +++ b/lib/util/data_blob.h @@ -104,6 +104,14 @@ _PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob); **/ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str); +/** + useful for constructing data blobs in test suites, while + avoiding const warnings + + includes the terminating null character (as opposed to data_blo_string_const) +**/ +_PUBLIC_ DATA_BLOB data_blob_string_const_null(const char *str); + /** * Create a new data blob from const data */ -- cgit