[petsc-dev] Allocating arrays
Jed Brown
jedbrown at mcs.anl.gov
Sat Nov 30 19:34:26 CST 2013
Barry Smith <bsmith at mcs.anl.gov> writes:
> I propose the following alternative:
>
> Remove the type arguments from PetscMalloc2-7()
I'm happy to do this. I think I can almost entirely automate it.
I agree that these functions are almost exclusively used internally, and
I think that every use in PETSc matches the types, so there is no point
keeping the old versions.
> Add PetscMalloc1()
>
> Add PetscCalloc1()
>
> Use PetscCalloc1() to implement PetscNew()
PetscCalloc1 *is* PetscNew. I would prefer "calloc" since it matches a
libc function that does the same thing, where as "new" conjures up
images of C++, where "new" only initializes non-POD types (which
includes std::complex<double>, but not struct {double real,imag;}). So
perhaps replace all uses of PetscNew with PetscCalloc1?
I wonder how many uses of PetscNew should have actually been PetscNewLog.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20131130/3b84dcc0/attachment.sig>
More information about the petsc-dev
mailing list