"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 always PIC, for the sake of argument).

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.  The method described by Mart is one.
For readers of this list, it boils down to turning:

static const char *foo[] = {"one", "two", "three" };

into:

static const char foo_data[] = "one\0two\0three";
static const foo_ind[] = {0, 4, 8};

static const char *foo(int ind) {
  return foo_data[foo_data + foo_ind[ind]];
}

(This technique was made popular by Ulrich Drepper.)

Maintaining the array of indices manually is cumbersome, but you could
write a tool that created the above three things from the original
const char *foo[] array without any user intervention.  But again,
that is total overkill for a non-PIC like Wget, and most likely for
smaller PICs as well.

Reply via email to