diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-08-07 20:59:28 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:00:27 -0500 |
commit | db8c38340b35574fc553b5ef7019f942699356f4 (patch) | |
tree | 986d7e824a68db139b13d14c94d8faf31b5bd888 /source3/lib | |
parent | fd6dde216168fba678346c2520051ddc63e70ae5 (diff) | |
download | samba-db8c38340b35574fc553b5ef7019f942699356f4.tar.gz samba-db8c38340b35574fc553b5ef7019f942699356f4.tar.bz2 samba-db8c38340b35574fc553b5ef7019f942699356f4.zip |
r9198: Convert hex_encode and strhex_to_data_blob to take a talloc context.
Volker
(This used to be commit c7d10e2c834d8d5136e2d01dea1ad286757deddb)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_str.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 1401d6d853..1252c6756b 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -795,9 +795,14 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex) return num_chars; } -DATA_BLOB strhex_to_data_blob(const char *strhex) +DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) { - DATA_BLOB ret_blob = data_blob(NULL, strlen(strhex)/2+1); + DATA_BLOB ret_blob; + + if (mem_ctx != NULL) + ret_blob = data_blob_talloc(mem_ctx, NULL, strlen(strhex)/2+1); + else + data_blob(NULL, strlen(strhex)/2+1); ret_blob.length = strhex_to_str((char*)ret_blob.data, strlen(strhex), @@ -810,16 +815,17 @@ DATA_BLOB strhex_to_data_blob(const char *strhex) * Routine to print a buffer as HEX digits, into an allocated string. */ -void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) +char *hex_encode(TALLOC_CTX *mem_ctx, const unsigned char *buff_in, size_t len) { int i; char *hex_buffer; - *out_hex_buffer = SMB_XMALLOC_ARRAY(char, (len*2)+1); - hex_buffer = *out_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; } /** |