[petsc-dev] please stop using PetscMalloc() in new code
Barry Smith
bsmith at mcs.anl.gov
Sat Nov 15 00:08:43 CST 2014
Please stop using PetscMalloc() in the code whenever possible! When you write
ierr = PetscMalloc(n*sizeof(xxx), &yyy); or PetscMalloc(n*sizeof(*yyy),&yyy);
it is far better to write
ierr = PetscMalloc1(n,&yyy);
there is less likely to be errors with regard to the size of yyy.
A bunch of new uses of PetscMalloc() have crept into the code, please avoid them.
Also be aware that PetscNew() is available and should be used when possible as well as PetscCalloc1() that allocates the space and insures that it is zeroed.
Thanks
Barry
Yes I would like git to reject uses of PetscMalloc() while Jed thinks eyeballs can reject them (but eyeballs have done a pretty crappy job in recent months).
More information about the petsc-dev
mailing list