Avoid mixed malloc and delete[]