Re: [PATCH] Reduce COW sections data by marking data constant

2008-02-01 Thread Hrvoje Niksic
Diego 'Flameeyes' Pettenò [EMAIL PROTECTED] writes: It is a micro-optimisation, I admit that, but it's not just the indirection the problem. Pointers, and structures containing pointers, need to be runtime-relocated for shared libraries and PIC code (let's assume that shared libraries are

Re: [PATCH] Reduce COW sections data by marking data constant

2008-02-01 Thread Hrvoje Niksic
Diego 'Flameeyes' Pettenò [EMAIL PROTECTED] writes: On 01/feb/08, at 09:12, Hrvoje Niksic wrote: Even ignoring the fact that Wget is not a shared library, there are ways to solve this problem other than turning all char *foo[] into char foo[][MAXSIZE], which is, sorry, just lame and wasteful

Re: [PATCH] Reduce COW sections data by marking data constant

2008-02-01 Thread Diego 'Flameeyes' Pettenò
On 01/feb/08, at 09:12, Hrvoje Niksic wrote: Even ignoring the fact that Wget is not a shared library, there are ways to solve this problem other than turning all char *foo[] into char foo[][MAXSIZE], which is, sorry, just lame and wasteful in all but the most trivial examples. That's why I

Re: [PATCH] Reduce COW sections data by marking data constant

2008-02-01 Thread Micah Cowan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hrvoje Niksic wrote: Of course, the changes that introduce const without compromising maintainability, such as the constification of the Wp declaration in ftp-opie.c, are more than welcome. Indeed. In fact, even if Diego doesn't submit a patch

Re: [PATCH] Reduce COW sections data by marking data constant

2008-02-01 Thread Hrvoje Niksic
Micah Cowan [EMAIL PROTECTED] writes: Note that you could also do all the pointer maths up-front, leaving existing usage code the same, with something like: static const char foo_data[] = one\0two\0three; static const char * const foo = {foo_data + 0, foo_data + 4, foo_data + 8}; I

Re: [PATCH] Reduce COW sections data by marking data constant

2008-02-01 Thread Hrvoje Niksic
Micah Cowan [EMAIL PROTECTED] writes: Right. What I was meaning to prevent, though, is the need to do: foo[foo_data + foo_idx[i]] and instead do: foo[i] That is why my example had a foo function, which turns foo[i] to foo(i), but otherwise works the same. Using just foo[i] is

Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Micah Cowan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 (Forgot to CC the list. Also, my mailer seems to be screwing up the quotes. :( -M) Diego 'Flameeyes' Pettenò wrote: | As for maintainability, while a character pointer is easier to handle than a | character array, modern compilers warns you if you

Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Diego 'Flameeyes' Pettenò
On Friday 01 February 2008, you wrote: Yes; but I still have to manually increment the size to an appropriate value each time I add a bigger string; plus I'm wasting space for all shorter strings (which applies more to bigger-than-two-element char arrays); Actually, you're not always. The

Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Josh Williams
On Jan 31, 2008 8:21 PM, Diego 'Flameeyes' Pettenò [EMAIL PROTECTED] wrote: char *foo = ab - 4 + 3 = 9 bytes How did you get 9?

Re: [PATCH] Reduce COW sections data by marking data constant

2008-01-31 Thread Diego 'Flameeyes' Pettenò
On 01/feb/08, at 02:33, Josh Williams wrote: How did you get 9? Probably by being 2:21 AM here ;) Sorry just a thinko.