summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/util/data_blob.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/util/data_blob.c b/lib/util/data_blob.c
index 3448e94316..10864a025b 100644
--- a/lib/util/data_blob.c
+++ b/lib/util/data_blob.c
@@ -33,6 +33,14 @@ const DATA_BLOB data_blob_null = { NULL, 0 };
**/
_PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *name)
{
+ return data_blob_talloc_named(NULL, p, length, name);
+}
+
+/**
+ construct a data blob, using supplied TALLOC_CTX
+**/
+_PUBLIC_ DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name)
+{
DATA_BLOB ret;
if (p == NULL && length == 0) {
@@ -41,9 +49,9 @@ _PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *nam
}
if (p) {
- ret.data = (uint8_t *)talloc_memdup(NULL, p, length);
+ ret.data = (uint8_t *)talloc_memdup(mem_ctx, p, length);
} else {
- ret.data = talloc_array(NULL, uint8_t, length);
+ ret.data = talloc_array(mem_ctx, uint8_t, length);
}
if (ret.data == NULL) {
ret.length = 0;
@@ -55,19 +63,6 @@ _PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *nam
}
/**
- construct a data blob, using supplied TALLOC_CTX
-**/
-_PUBLIC_ DATA_BLOB data_blob_talloc_named(TALLOC_CTX *mem_ctx, const void *p, size_t length, const char *name)
-{
- DATA_BLOB ret = data_blob_named(p, length, name);
-
- if (ret.data) {
- talloc_steal(mem_ctx, ret.data);
- }
- return ret;
-}
-
-/**
construct a zero data blob, using supplied TALLOC_CTX.
use this sparingly as it initialises data - better to initialise
yourself if you want specific data in the blob