FIX: if the new size is less than the current one, accordingly free memory
FIX: if the new size is less than the current one, accordingly free memory

Former-commit-id: 01e4cb4b5b25ea5a94fbdfa66ebecad0071bbae5
hdeling/sofa,hdeling/sofa,hdeling/sofa,FabienPean/sofa,Anatoscope/sofa,hdeling/sofa,hdeling/sofa,Anatoscope/sofa,FabienPean/sofa,FabienPean/sofa,FabienPean/sofa,hdeling/sofa,hdeling/sofa,hdeling/sofa,Anatoscope/sofa,Anatoscope/sofa,FabienPean/sofa,Anatoscope/sofa,FabienPean/sofa,Anatoscope/sofa,hdeling/sofa,FabienPean/sofa,Anatoscope/sofa,Anatoscope/sofa,FabienPean/sofa,Anatoscope/sofa,hdeling/sofa,FabienPean/sofa,FabienPean/sofa