[petsc-dev] Add PetscFree1() ?

Jed Brown jed at jedbrown.org
Thu Apr 5 23:06:13 CDT 2018


PetscFree and PetscFree1 would be equivalent so I don't think it's
needed, but wouldn't object if you feel strongly about it.

Lots of macros should not be.  I think PetscFree can use PetscFreeA
which would evaluate its argument only once while still guaranteeing
that it be zeroed.

Lisandro Dalcin <dalcinl at gmail.com> writes:

> Jed, just for the sake of consistency, don't we need PetscFree1()?
>
> Also, PetscFree() is a macro, and evaluates twice the first arg, I
> just had to fix a bug in my code that was doing
>
> while (ctx->size > 0)
>     PetscFree(ctx->arrayOfPointers[--ctx->size]);
> PetscFree(ctx->arrayOfPointers)
>
>
> I guess we should just rewrite PetscFree() to be safer, but too close
> to release right now to play these games...
>
> -- 
> Lisandro Dalcin
> ============
> Research Scientist
> Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
> Extreme Computing Research Center (ECRC)
> King Abdullah University of Science and Technology (KAUST)
> http://ecrc.kaust.edu.sa/
>
> 4700 King Abdullah University of Science and Technology
> al-Khawarizmi Bldg (Bldg 1), Office # 0109
> Thuwal 23955-6900, Kingdom of Saudi Arabia
> http://www.kaust.edu.sa
>
> Office Phone: +966 12 808-0459


More information about the petsc-dev mailing list