Browse code

tools/ffhash: use av_hash_final_hex().

Nicolas George authored on 2014/04/22 00:22:22
Showing 1 changed files
... ...
@@ -40,7 +40,6 @@
40 40
 #define SIZE 65536
41 41
 
42 42
 static struct AVHashContext *hash;
43
-static uint8_t *res;
44 43
 
45 44
 static void usage(void)
46 45
 {
... ...
@@ -60,12 +59,10 @@ static void usage(void)
60 60
 
61 61
 static void finish(void)
62 62
 {
63
-    int i, len = av_hash_get_size(hash);
63
+    char res[2 * AV_HASH_MAX_SIZE + 1];
64 64
 
65
-    printf("%s=0x", av_hash_get_name(hash));
66
-    av_hash_final(hash, res);
67
-    for (i = 0; i < len; i++)
68
-        printf("%02x", res[i]);
65
+    av_hash_final_hex(hash, res, sizeof(res));
66
+    printf("%s=0x%s", av_hash_get_name(hash), res);
69 67
 }
70 68
 
71 69
 static int check(char *file)
... ...
@@ -130,11 +127,6 @@ int main(int argc, char **argv)
130 130
         }
131 131
         return 1;
132 132
     }
133
-    res = av_malloc(av_hash_get_size(hash));
134
-    if (!res) {
135
-        printf("%s\n", strerror(errno));
136
-        return 1;
137
-    }
138 133
 
139 134
     for (i = 2; i < argc; i++)
140 135
         ret |= check(argv[i]);
... ...
@@ -143,7 +135,6 @@ int main(int argc, char **argv)
143 143
         ret |= check(NULL);
144 144
 
145 145
     av_hash_freep(&hash);
146
-    av_freep(&res);
147 146
 
148 147
     return ret;
149 148
 }