|
From: Daniel J S. <dan...@ie...> - 2007-06-30 20:22:28
|
Hans-Bernhard Bröker wrote: > 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 '&'. Naturally. I was typing away and not paying attention. The compiler weeds out such typos. > >> 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. > 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? I could use a pointer to a dynarray in the plot struct, and then gp_malloc memory for the dynarray only if it is needed. But that gets to be programming spaghetti. If one could init the size to zero and on the first "nextfrom_dynarray" the array is extended by this->increment, what's wrong with that? > >> 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. Dan |