summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-05-18 09:57:29 -0700
committerGünther Deschner <gd@samba.org>2010-05-18 21:57:23 +0200
commit829c87634b2aca87789371ad33231e9d4bc518a8 (patch)
treef1f76385ca24030eaf469c7c7fdd2f36d5fbbae0 /lib/util
parentf6f3bb1813b5f030616e422ed420b938244be84e (diff)
downloadsamba-829c87634b2aca87789371ad33231e9d4bc518a8.tar.gz
samba-829c87634b2aca87789371ad33231e9d4bc518a8.tar.bz2
samba-829c87634b2aca87789371ad33231e9d4bc518a8.zip
Change data_blob() to be based on top of data_blob_talloc(), instead of the reverse (as it is now).
It makes no sense to talloc off the null context, then talloc steal into the required context - just talloc off the correct context, and change data_blob() to pass in the null context to data_blob_talloc(). Jeremy. Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'lib/util')
-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