>> > Maybe this would do >> > >> > double *p=third_party_function(nn); >> > NumericVector ret(nn); // new memory >> > copy(ret.begin(), ret.end(), p); // untested >> > delete p; >> > return ret; >> > >>> | where third_party_function() is C legacy code that is >>> documented as | returning a block of memory of size nn that the >>> client should take | ownership of.
> If third_party_function is really C legacy code, wouldn't the block > of code be more likely to have been allocated with a 'malloc', and > so you should release it with a 'free'? Good point :-) The legacy code API will tell me how it should be deleted. (With some APIs it will be a special function.) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel