Fixes a bug with alt_buf_write_t lifetime.

I also checked all of the alt_buf_write_t and made sure the lifetime is
safe.