Greg Ercolano wrote:
>
> -1 on the mod for QCHAR_ENTRY() in quote_char(), as that causes
> twice as much memory to be used for the strings. ie. your macro use of:
>
> ----
> #define QCHAR_ENTRY(aname, i1, i2) { #aname, sizeof(#aname), ENC(i1,i2) }
> [..]
> names[] = // Quoting names
> {
> QCHAR_ENTRY("AElig;", 198, 174),
> QCHAR_ENTRY("Aacute;", 193, 231),
> QCHAR_ENTRY("Acirc;", 194, 229),
> ----
>
> ..will be sent to the compiler as something like:
>
> ----
> names[] = // Quoting names
> {
> { "AElig;", sizeof("AElig;"), ENC(198,174) }
> -------- --------
> \_______________\__________ compiler will allocate two
> separate strings in the lib
>
> ----
>
> Depending on the optimization of the compiler, this will double
> memory use, and doesn't optimize for speed. (But it does protect
> against coding mistakes)
>
I thought like you before know that the compiler actually only allocate
one copy for any repeated constant string, and remember sizeof() isn't a
function it's a compile time calculation, so there is no double memory
consumption !
You can test it by yourself with something like this:
#include <stdio.h>
const char *str1() {return "unique";}
const char *str2() {return "unique";}
const char *str3() {return "unique";}
int main()
{
printf("%p = %p = %p\n", str1(), str2(), str3());
return 0;
}
output on my machine: 00403000 = 00403000 = 00403000
About format style I'm using codeblocks astyle plugin to format the
code, I understand the problem created with a different formatting style
but to make the original source understandable and help recoding it the
reformat was a lot helpful.
And thanks for alert me about tab been expanded, I chanhed my setting ad
now the file size is smaller.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev