From 702372b343cd764b51f29fc0d6bf512197d2372d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 08:07:42 +0000 Subject: r23807: added hex_encode_talloc() (This used to be commit 1b105097e3f4a8475d3a2623205ecdea2aef91cf) --- source4/lib/util/util_str.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4') diff --git a/source4/lib/util/util_str.c b/source4/lib/util/util_str.c index 80a22773d4..baa42e806a 100644 --- a/source4/lib/util/util_str.c +++ b/source4/lib/util/util_str.c @@ -244,6 +244,22 @@ _PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_he slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); } +/** + * talloc version of hex_encode() + */ +_PUBLIC_ char *hex_encode_talloc(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len) +{ + int i; + char *hex_buffer; + + hex_buffer = talloc_array(mem_ctx, char, (len*2)+1); + + for (i = 0; i < len; i++) + slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); + + return hex_buffer; +} + /** Set a string value, allocing the space for the string **/ -- cgit