From 3a34d0c08a77ee48edc3f4353cc49b95aba85c2f Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 12 Jan 2007 22:10:34 +0000 Subject: random small size optimizations --- coreutils/md5_sha1_sum.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'coreutils') diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 6fe1b0286..014ecefd0 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c @@ -18,11 +18,9 @@ typedef enum { HASH_SHA1, HASH_MD5 } hash_algo_t; static unsigned char *hash_bin_to_hex(unsigned char *hash_value, unsigned hash_length) { - int len = 0; - char *hex_value = xmalloc((hash_length * 2) + 2); - while (hash_length--) { - len += sprintf(hex_value + len, "%02x", *hash_value++); - } + /* xzalloc zero-terminates */ + char *hex_value = xzalloc((hash_length * 2) + 1); + bin2hex(hex_value, (char*)hash_value, hash_length); return hex_value; } -- cgit v1.2.3