Auto resize input buffer in steps of 4096 bytes, free() afterwards.