Barry Smith <[email protected]> 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.
pgpiDUrOGBdF7.pgp
Description: PGP signature
