Frees a result 'r' and if free_data is true also frees the internal r->data result too.
See Implementation
Frees a result 'r' and if free_data is true also frees the internal r->data result too.