make fmemopen's w+ mode truncate the buffer