|
From:
<br...@ph...> - 2006-02-22 15:12:13
|
Bastian Maerkisch wrote: > The crucial point is that the maximum increase of the points[] > array is limited to 1000. I'm pretty sure that test is plain and buggily ass-backwards. The general approach to avoid excessively frequent realloc()s is to double the allocation size each time you have to grow it. I'm guessing here, but that business with 1000 is probably intended to avoid the early, rather pointless early stages of that process, i.e. to ensure that the allocation alwyas grows by *at least* 1000, not at most 1000. > eliminates that problem, but uses exceedingly large amounts > of memory. Factor of 2 of waste is not really excessive. But if you don't like it, it can always be replaced by something like new_size = (1.5 * old_size + 1000) Call me biased, but I suspect this code had better use the existing dynarray.h stuff instead. I broke that code out of hidden3d for a reason, see? |