I find it generally more idiomatic when input-only parameters aren't freed by default; this would also obviate that "else" below.
This will eventually be called from a different place, and samples be reference counted. I think it's best for the helper to take the ownership.