[petsc-dev] PetscMalloc for size zero
Jed Brown
jed at jedbrown.org
Thu Jan 30 14:15:26 CST 2014
Barry Smith <bsmith at mcs.anl.gov> writes:
>> Here is what I suggestion. Someone suggest (i.e.. write) a refactorization of PetscMalloc(), PetscMallocn() that handles correctly any of the sizes being zero correctly in a branch and see how it goes.
>>
>> I have pushed it. It looks simple to me
>
> I don’t see how this can possibly work
>
> #if defined(PETSC_USE_DEBUG)
> #define PetscFree2(m1,m2) (PetscFree(m2) || PetscFree(m1))
> #else
> #define PetscFree2(m1,m2) ((m2)=0, PetscFree(m1))
> #endif
>
> You need to free the first m[i] that is not null. If m1 was null in the optimized form you never free anything.
>
> These macros are getting horrible, can they become something cleaner?
Why do we want this behavior? Can we see some concrete code that is
affected by this behavior? We needed PetscMalloc[2-7] to work in
optimized mode, so nothing in PETSc should be depending on it.
-------------- 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/20140130/7df5b481/attachment.sig>
More information about the petsc-dev
mailing list