Pass in opt buffer to prevent extra malloc