I would just allocate a vector that is the biggest you will need and use that,
only freeing it at the end. If you can't do that for some reason, then use resize.