[FFmpeg-devel] [PATCH] Simplify table definitions in ff_data_to_hex
Ronald S. Bultje
rsbultje
Thu Mar 25 15:30:33 CET 2010
Hi,
On Thu, Mar 25, 2010 at 10:23 AM, Luca Abeni <lucabe72 at email.it> wrote:
> - ? ?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"
If we don't care about the 1 byte wasted on the terminating zero here,
we should at least use table[], not *table, otherwise we'll waste
another couple of bytes on a pointer.
Martin says the binary actually changes if you do [16] = "..", which
appears to be due to the zero. This surprises me a bit. Can that be
prevented? Any gcc experts here?
Ronald
More information about the ffmpeg-devel
mailing list