Replace allocated buffer size by string length.