On Sun, 13 Dec 2009 18:56:46 -0600, Matthew Knepley <knepley at gmail.com> wrote: > > DM *tmp; > > DMRefineHierarchy(dmc,1,&tmp); > > dmf = *tmp; > > PetscFree(tmp); > > > > I am not sure why this is much worse. There are many things users are > required to destroy.
You must agree that it's clunky considering that the alternative would be DMRefineHierarchy(dmc,1,&dmf); Callee-allocates is especially awkward when DMRefineHierarchy is being used in the implementation of DMRefineHierarchy (e.g. in my case where part of the hierarchy is conventional while another part is custom). Besides, most things that the user has to free come with a dedicated API to free them (usually XRestoreY) which doesn't make sense here. And the current callee-allocates was not actually correct: mesh.c:1865 creates more new meshes than it should and the last one is never populated (Hierarchy.hh:1179) so something nontrivial was leaking. I don't particularly care, but I think caller-allocates amounts to less code (when averaged over the common cases) and more obvious semantics. Jed
