[FFmpeg-devel] [PATCH] Simplify table definitions in ff_data_to_hex

Luca Abeni lucabe72
Thu Mar 25 15:23:12 CET 2010


Hi Martin,

Martin Storsj? wrote:
> Hi,
> 
> As in $subj, declare the binary->hex mapping tables using a string instead 
> of an array of chars - makes the code a bit shorter and easier to read 
> imo.
[...]
  char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
  {
      int i;
-    static const char hex_table_uc[16] = { '0', '1', '2', '3',
-                                           '4', '5', '6', '7',
-                                           '8', '9', 'A', 'B',
-                                           'C', 'D', 'E', 'F' };
-    static const char hex_table_lc[16] = { '0', '1', '2', '3',
-                                           '4', '5', '6', '7',
-                                           '8', '9', 'a', 'b',
-                                           'c', 'd', 'e', 'f' };
+    static const char hex_table_uc[16] = "0123456789ABCDEF";
+    static const char hex_table_lc[16] = "0123456789abcdef";

This looks strange: "0123456789ABCDEF" is 17 bytes, not 16...
I'd use
	const char *hex_table_uc = "0123456789ABCDEF"


			Luca



More information about the ffmpeg-devel mailing list