summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-07-10 08:07:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:59:20 -0500
commit702372b343cd764b51f29fc0d6bf512197d2372d (patch)
treed26a58d1f46b732edf3846cd7a16be9d800dc33a
parent6504900f1f52927adab3489b8d04b6644ceaee7d (diff)
downloadsamba-702372b343cd764b51f29fc0d6bf512197d2372d.tar.gz
samba-702372b343cd764b51f29fc0d6bf512197d2372d.tar.bz2
samba-702372b343cd764b51f29fc0d6bf512197d2372d.zip
r23807: added hex_encode_talloc()
(This used to be commit 1b105097e3f4a8475d3a2623205ecdea2aef91cf)
-rw-r--r--source4/lib/util/util_str.c16
1 files changed, 16 insertions, 0 deletions
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
@@ -245,6 +245,22 @@ _PUBLIC_ void hex_encode(const unsigned char *buff_in, size_t len, char **out_he
}
/**
+ * 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
**/
static BOOL string_init(char **dest,const char *src)