This is along the lines of heap allocation...sorry, but I have no code to illustrate...
I have a function that needs a variable sized buffer, but that [red]exact[/red] size isn't known until we already are calculating using the buffer, and we run out of space. However, what I can pre-calculate is the [red]maximum[/red] size the buffer could be given some other variables, the least size that the worse case scenario can use and still work.
Well, the buffer is returned (sorta, rather the buffer in the first place wasn't the function's, but it is the buffer the result is stored in; it may be sized to fit the whole answer). So afterwards, I need to remove the excess space, and that means I wasted space...
However, if I go the other way, the algorithm would be slow...my logic is to go with the former...but me, hardly a novice, I wonder if my logic holds for you guys.
thats all, thanx all of you(or just Lundin or Niklas,it'll probably be you two to reply)
0 · ·