1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-14 20:23:54 +03:00

r23807: added hex_encode_talloc()

(This used to be commit 1b105097e3)
This commit is contained in:
Andrew Tridgell
2007-07-10 08:07:42 +00:00
committed by Gerald (Jerry) Carter
parent 6504900f1f
commit 702372b343

View File

@@ -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
**/