|
From: <HBB...@t-...> - 2007-06-30 20:03:16
|
Daniel J Sebald wrote:
> If I do
>
> init_dynarray(foo_array, sizeof(foo), 0, 200);
Then you're already misusing the dynarray module. It's designed to be
called like this:
init_dynarray(&foo_array, sizeof(foo), 200, 200);
Note the '&'.
> That is, it seems it isn't possible to initialize
> the dynarray to size zero.
There's no point in doing that, so why would you want to? A dynarray of
size zero is about as useful as a pointer to nothing.
> It'd nice if one could. It's not of great importance, but for such a
> fundamental utility "consistency" (lack of term) would be nice.
Consistency with what?
> "world.dem", line 13: nextfrom_dynarray: dynarray wasn't initialized!
[...]
> Maybe it should be
>
> if (size <= 0) graph_error("foo"); this->v = ...
And how would that be any better than the above? It's just a different
error message, but no change of actual behaviour.
> It will save a test every time nextfrom_dynarray() is called (which
> is fairly considerable). Plus, let's say init_dynarray *wasn't*
> called.
Then size is zero --- that's why the test is done the way it is.
The control struct is supposed to be static, after all, so it's always
initialized to zero.
> gp_alloc uses "malloc" which isn't guaranteed to be zero
> (probably system dependent).
What would that have to do with anything?
|