Skip to content
Prev 15769 / 63461 Next

dynamic array output by .C

On Apr 14, 2005, at 6:01 PM, Tib wrote:

            
AFAIR you cannot extend vectors - it's like in C, you cannot extend  
allocated memory without changing the pointer (i.g.). In order to get  
a vector of a different size, you have to allocate a new one and copy  
the common contents. If you are concerned about efficiency, why don't  
you just use arbitrary large vectors and pass along the number of  
used elements? Then you can easily add elements without re-allocating  
and just return the number of elements used after the operation. That  
way you can control the probability of having to allocate a new  
vector, possibly making it zero.

Cheers,
Simon