From 829c87634b2aca87789371ad33231e9d4bc518a8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 May 2010 09:57:29 -0700 Subject: Change data_blob() to be based on top of data_blob_talloc(), instead of the reverse (as it is now). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/util/data_blob.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'lib') 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 @@ -32,6 +32,14 @@ const DATA_BLOB data_blob_null = { NULL, 0 }; you can pass NULL for p and get a blank data blob **/ _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; @@ -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; @@ -54,19 +62,6 @@ _PUBLIC_ DATA_BLOB data_blob_named(const void *p, size_t length, const char *nam return ret; } -/** - 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 -- cgit