From 30c15f37cc73f0beebceed009109542ba738d011 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 11 Jul 2004 06:51:58 +0000 Subject: r1435: talloc_steal is very useful - add a function to do it with a DATA_BLOB Andrew Bartlett (This used to be commit 66d6e2611084d579a20833a4c0daa5d72ef9393c) --- source4/lib/data_blob.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source4/lib/data_blob.c b/source4/lib/data_blob.c index 3667d453b9..a6e6672b90 100644 --- a/source4/lib/data_blob.c +++ b/source4/lib/data_blob.c @@ -99,6 +99,21 @@ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length) return blob; } +/** + * Steal a talloc'ed DATA_BLOB from one context to another + */ + +DATA_BLOB data_blob_talloc_steal(TALLOC_CTX *old_ctx, TALLOC_CTX *new_ctx, + DATA_BLOB *old) +{ + DATA_BLOB new; + new = *old; + new.data = talloc_steal(old_ctx, new_ctx, old->data); + if (new.data == NULL) { + smb_panic("data_blob_talloc_steal: talloc_steal failed.\n"); + } +} + /******************************************************************* free a data blob *******************************************************************/ -- cgit