diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-10-13 05:20:26 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-10-13 05:20:26 +0200 |
commit | aa982895e5c13497144740e90ff9646e1d1cf995 (patch) | |
tree | f21159a823cd8fd329dc073a841c576da2450fcc /lib/util | |
parent | d5a11f9679be9d053838074f1dad5a0ca880750f (diff) | |
download | samba-aa982895e5c13497144740e90ff9646e1d1cf995.tar.gz samba-aa982895e5c13497144740e90ff9646e1d1cf995.tar.bz2 samba-aa982895e5c13497144740e90ff9646e1d1cf995.zip |
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.
Diffstat (limited to 'lib/util')
-rw-r--r-- | lib/util/data_blob.c | 12 | ||||
-rw-r--r-- | lib/util/data_blob.h | 8 |
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); |