vec: factor out some deallocation code