summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/data_blob.c12
-rw-r--r--lib/util/data_blob.h8
2 files changed, 20 insertions, 0 deletions
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
@@ -183,6 +183,18 @@ _PUBLIC_ DATA_BLOB data_blob_string_const(const char *str)
}
/**
+ 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
@@ -105,6 +105,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
*/
_PUBLIC_ DATA_BLOB data_blob_const(const void *p, size_t length);