|
From: <HBB...@t-...> - 2007-06-30 20:49:20
|
Daniel J Sebald wrote: > Hans-Bernhard Bröker wrote: >> Daniel J Sebald wrote: >>> 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? > Because in the patch I'm doing I'm placing a dynarray in the plot > struct but it may not necessarily be used if no data is read from a > file, but instead the plot type is FUNC. So what would be the problem with delaying the init_dynarray() call until you actually need the thing? >> A dynarray of size zero is about as useful as a pointer to nothing. > Why assign memory if it isn't going to be used? By not doing it yet. Do it when you know you'll need it. >>> 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? > Again, the issue is that such familiarity with the dynarray code is > assumed (e.g., "Why set to zero? That's silly.") that the test > *which is not failsafe as I argued* seems extraneous. The test may not be failsafe, but it's necessary, and correct as it is. Among other things, have a look at free_dynarray(). The state this leaves the dynarray struct in has to be tested against, as well as the automatic all-zeroes state of the struct. |