diff options
Diffstat (limited to 'src')
136 files changed, 935 insertions, 924 deletions
diff --git a/src/PJ_aea.cpp b/src/PJ_aea.cpp index 88929e3b..c4a4a72a 100644 --- a/src/PJ_aea.cpp +++ b/src/PJ_aea.cpp @@ -85,10 +85,10 @@ struct pj_opaque { static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -199,7 +199,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(aea) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -212,7 +212,7 @@ PJ *PROJECTION(aea) { PJ *PROJECTION(leac) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; diff --git a/src/PJ_aeqd.cpp b/src/PJ_aeqd.cpp index 69bb76c3..1a350d90 100644 --- a/src/PJ_aeqd.cpp +++ b/src/PJ_aeqd.cpp @@ -63,10 +63,10 @@ PROJ_HEAD(aeqd, "Azimuthal Equidistant") "\n\tAzi, Sph&Ell\n\tlat_0 guam"; static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -270,7 +270,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(aeqd) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; diff --git a/src/PJ_affine.cpp b/src/PJ_affine.cpp index c53d4e60..e2b668d3 100644 --- a/src/PJ_affine.cpp +++ b/src/PJ_affine.cpp @@ -112,8 +112,8 @@ static LP reverse_2d(XY xy, PJ *P) { static struct pj_opaque_affine * initQ() { struct pj_opaque_affine *Q = static_cast<struct pj_opaque_affine *>(pj_calloc(1, sizeof(struct pj_opaque_affine))); - if (0==Q) - return 0; + if (nullptr==Q) + return nullptr; /* default values */ Q->forward.s11 = 1.0; @@ -157,9 +157,9 @@ static void computeReverseParameters(PJ* P) if (proj_log_level(P->ctx, PJ_LOG_TELL) >= PJ_LOG_DEBUG) { proj_log_debug(P, "Affine: matrix non invertible"); } - P->inv4d = NULL; - P->inv3d = NULL; - P->inv = NULL; + P->inv4d = nullptr; + P->inv3d = nullptr; + P->inv = nullptr; } else { Q->reverse.s11 = A / det; Q->reverse.s12 = D / det; @@ -176,7 +176,7 @@ static void computeReverseParameters(PJ* P) PJ *TRANSFORMATION(affine,0 /* no need for ellipsoid */) { struct pj_opaque_affine *Q = initQ(); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = (void *) Q; @@ -227,7 +227,7 @@ PJ *TRANSFORMATION(affine,0 /* no need for ellipsoid */) { PJ *TRANSFORMATION(geogoffset,0 /* no need for ellipsoid */) { struct pj_opaque_affine *Q = initQ(); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = (void *) Q; diff --git a/src/PJ_airy.cpp b/src/PJ_airy.cpp index fa159bae..0eb5efd7 100644 --- a/src/PJ_airy.cpp +++ b/src/PJ_airy.cpp @@ -116,7 +116,7 @@ PJ *PROJECTION(airy) { double beta; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_aitoff.cpp b/src/PJ_aitoff.cpp index ba1402a4..effd2c29 100644 --- a/src/PJ_aitoff.cpp +++ b/src/PJ_aitoff.cpp @@ -175,7 +175,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(aitoff) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -186,7 +186,7 @@ PJ *PROJECTION(aitoff) { PJ *PROJECTION(wintri) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_august.cpp b/src/PJ_august.cpp index e891e84e..b5a21ef7 100644 --- a/src/PJ_august.cpp +++ b/src/PJ_august.cpp @@ -27,7 +27,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(august) { - P->inv = 0; + P->inv = nullptr; P->fwd = s_forward; P->es = 0.; return P; diff --git a/src/PJ_axisswap.cpp b/src/PJ_axisswap.cpp index 69edac8b..8714ec85 100644 --- a/src/PJ_axisswap.cpp +++ b/src/PJ_axisswap.cpp @@ -167,7 +167,7 @@ PJ *CONVERSION(axisswap,0) { char *s; unsigned int i, j, n = 0; - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = (void *) Q; @@ -189,7 +189,7 @@ PJ *CONVERSION(axisswap,0) { /* check that all characters are valid */ for (i=0; i<strlen(order); i++) - if (strchr("1234-,", order[i]) == 0) { + if (strchr("1234-,", order[i]) == nullptr) { proj_log_error(P, "axisswap: unknown axis '%c'", order[i]); return pj_default_destructor(P, PJD_ERR_AXIS); } @@ -275,7 +275,7 @@ PJ *CONVERSION(axisswap,0) { } - if (P->fwd4d == NULL && P->fwd3d == NULL && P->fwd == NULL) { + if (P->fwd4d == nullptr && P->fwd3d == nullptr && P->fwd == nullptr) { proj_log_error(P, "swapaxis: bad axis order"); return pj_default_destructor(P, PJD_ERR_AXIS); } diff --git a/src/PJ_bacon.cpp b/src/PJ_bacon.cpp index b00e1523..6c6350fe 100644 --- a/src/PJ_bacon.cpp +++ b/src/PJ_bacon.cpp @@ -42,7 +42,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(bacon) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -56,7 +56,7 @@ PJ *PROJECTION(bacon) { PJ *PROJECTION(apian) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -69,7 +69,7 @@ PJ *PROJECTION(apian) { PJ *PROJECTION(ortel) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_bertin1953.cpp b/src/PJ_bertin1953.cpp index a551a6b2..2203d6f1 100644 --- a/src/PJ_bertin1953.cpp +++ b/src/PJ_bertin1953.cpp @@ -77,7 +77,7 @@ static XY s_forward (LP lp, PJ *P) { PJ *PROJECTION(bertin1953) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_bipc.cpp b/src/PJ_bipc.cpp index 95cbcbb8..19a6bbe1 100644 --- a/src/PJ_bipc.cpp +++ b/src/PJ_bipc.cpp @@ -164,7 +164,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(bipc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_bonne.cpp b/src/PJ_bonne.cpp index 0e979f64..385c1c4b 100644 --- a/src/PJ_bonne.cpp +++ b/src/PJ_bonne.cpp @@ -90,10 +90,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -104,7 +104,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor PJ *PROJECTION(bonne) { double c; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -115,7 +115,7 @@ PJ *PROJECTION(bonne) { if (P->es != 0.0) { Q->en = pj_enfn(P->es); - if (0==Q->en) + if (nullptr==Q->en) return destructor(P, ENOMEM); Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1), c = cos(Q->phi1), Q->en); diff --git a/src/PJ_calcofi.cpp b/src/PJ_calcofi.cpp index ed4cfe86..e81e4d2a 100644 --- a/src/PJ_calcofi.cpp +++ b/src/PJ_calcofi.cpp @@ -141,7 +141,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(calcofi) { - P->opaque = 0; + P->opaque = nullptr; /* if the user has specified +lon_0 or +k0 for some reason, we're going to ignore it so that xy is consistent with point O */ diff --git a/src/PJ_cass.cpp b/src/PJ_cass.cpp index 2488f405..c831558c 100644 --- a/src/PJ_cass.cpp +++ b/src/PJ_cass.cpp @@ -84,10 +84,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ } static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -107,12 +107,12 @@ PJ *PROJECTION(cass) { /* otherwise it's ellipsoidal */ P->opaque = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, ENOMEM); P->destructor = destructor; static_cast<struct pj_opaque*>(P->opaque)->en = pj_enfn (P->es); - if (0==static_cast<struct pj_opaque*>(P->opaque)->en) + if (nullptr==static_cast<struct pj_opaque*>(P->opaque)->en) return pj_default_destructor (P, ENOMEM); static_cast<struct pj_opaque*>(P->opaque)->m0 = pj_mlfn (P->phi0, sin (P->phi0), cos (P->phi0), static_cast<struct pj_opaque*>(P->opaque)->en); diff --git a/src/PJ_ccon.cpp b/src/PJ_ccon.cpp index 4ee53133..4f7dedb4 100644 --- a/src/PJ_ccon.cpp +++ b/src/PJ_ccon.cpp @@ -69,10 +69,10 @@ static LP inverse (XY xy, PJ *P) { static PJ *destructor (PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -83,7 +83,7 @@ static PJ *destructor (PJ *P, int errlev) { PJ *PROJECTION(ccon) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; diff --git a/src/PJ_cea.cpp b/src/PJ_cea.cpp index 3c9e128d..f8275b62 100644 --- a/src/PJ_cea.cpp +++ b/src/PJ_cea.cpp @@ -59,10 +59,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ } static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->apa); @@ -73,7 +73,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor PJ *PROJECTION(cea) { double t = 0.0; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; diff --git a/src/PJ_chamb.cpp b/src/PJ_chamb.cpp index 0da3899b..a490e817 100644 --- a/src/PJ_chamb.cpp +++ b/src/PJ_chamb.cpp @@ -104,7 +104,7 @@ PJ *PROJECTION(chamb) { int i, j; char line[10]; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_deformation.cpp b/src/PJ_deformation.cpp index 49f62c01..6c30f21c 100644 --- a/src/PJ_deformation.cpp +++ b/src/PJ_deformation.cpp @@ -248,10 +248,10 @@ static PJ_COORD reverse_4d(PJ_COORD in, PJ *P) { } static PJ *destructor(PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); if (static_cast<struct pj_opaque*>(P->opaque)->cart) @@ -265,12 +265,12 @@ PJ *TRANSFORMATION(deformation,1) { int has_xy_grids = 0; int has_z_grids = 0; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return destructor(P, ENOMEM); P->opaque = (void *) Q; Q->cart = proj_create(P->ctx, "+proj=cart"); - if (Q->cart == 0) + if (Q->cart == nullptr) return destructor(P, ENOMEM); /* inherit ellipsoid definition from P to Q->cart */ @@ -313,8 +313,8 @@ PJ *TRANSFORMATION(deformation,1) { P->inv4d = reverse_4d; P->fwd3d = forward_3d; P->inv3d = reverse_3d; - P->fwd = 0; - P->inv = 0; + P->fwd = nullptr; + P->inv = nullptr; P->left = PJ_IO_UNITS_CARTESIAN; P->right = PJ_IO_UNITS_CARTESIAN; diff --git a/src/PJ_eck3.cpp b/src/PJ_eck3.cpp index beaf9357..90376631 100644 --- a/src/PJ_eck3.cpp +++ b/src/PJ_eck3.cpp @@ -52,7 +52,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(eck3) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -67,7 +67,7 @@ PJ *PROJECTION(eck3) { PJ *PROJECTION(kav7) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -85,7 +85,7 @@ PJ *PROJECTION(kav7) { PJ *PROJECTION(wag6) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -99,7 +99,7 @@ PJ *PROJECTION(wag6) { PJ *PROJECTION(putp1) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_eqc.cpp b/src/PJ_eqc.cpp index f31da20a..3fdb6dc0 100644 --- a/src/PJ_eqc.cpp +++ b/src/PJ_eqc.cpp @@ -40,7 +40,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(eqc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_eqdc.cpp b/src/PJ_eqdc.cpp index 7e5cd0da..0831fca4 100644 --- a/src/PJ_eqdc.cpp +++ b/src/PJ_eqdc.cpp @@ -61,10 +61,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -77,7 +77,7 @@ PJ *PROJECTION(eqdc) { int secant; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; diff --git a/src/PJ_eqearth.cpp b/src/PJ_eqearth.cpp index 3547d683..e5c1f974 100644 --- a/src/PJ_eqearth.cpp +++ b/src/PJ_eqearth.cpp @@ -130,10 +130,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal/spheroidal, invers } static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->apa); @@ -143,7 +143,7 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ PJ *PROJECTION(eqearth) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -154,7 +154,7 @@ PJ *PROJECTION(eqearth) { /* Ellipsoidal case */ if (P->es != 0.0) { Q->apa = pj_authset(P->es); /* For auth_lat(). */ - if (0 == Q->apa) + if (nullptr == Q->apa) return destructor(P, ENOMEM); Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */ Q->rqda = sqrt(0.5*Q->qp); /* Authalic radius divided by major axis */ diff --git a/src/PJ_fouc_s.cpp b/src/PJ_fouc_s.cpp index 6f046b0a..c5e711de 100644 --- a/src/PJ_fouc_s.cpp +++ b/src/PJ_fouc_s.cpp @@ -56,7 +56,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(fouc_s) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_geos.cpp b/src/PJ_geos.cpp index 6bf7c3f3..90fb01ab 100644 --- a/src/PJ_geos.cpp +++ b/src/PJ_geos.cpp @@ -198,7 +198,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ *PROJECTION(geos) { char *sweep_axis; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -206,7 +206,7 @@ PJ *PROJECTION(geos) { return pj_default_destructor (P, PJD_ERR_H_LESS_THAN_ZERO); sweep_axis = pj_param(P->ctx, P->params, "ssweep").s; - if (sweep_axis == NULL) + if (sweep_axis == nullptr) Q->flip_axis = 0; else { if ((sweep_axis[0] != 'x' && sweep_axis[0] != 'y') || diff --git a/src/PJ_gins8.cpp b/src/PJ_gins8.cpp index c1a2fff0..cc422437 100644 --- a/src/PJ_gins8.cpp +++ b/src/PJ_gins8.cpp @@ -24,7 +24,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(gins8) { P->es = 0.0; - P->inv = 0; + P->inv = nullptr; P->fwd = s_forward; return P; diff --git a/src/PJ_gn_sinu.cpp b/src/PJ_gn_sinu.cpp index c9885012..530de229 100644 --- a/src/PJ_gn_sinu.cpp +++ b/src/PJ_gn_sinu.cpp @@ -93,10 +93,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -118,7 +118,7 @@ static void setup(PJ *P) { PJ *PROJECTION(sinu) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -140,7 +140,7 @@ PJ *PROJECTION(sinu) { PJ *PROJECTION(eck6) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -155,7 +155,7 @@ PJ *PROJECTION(eck6) { PJ *PROJECTION(mbtfps) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -170,7 +170,7 @@ PJ *PROJECTION(mbtfps) { PJ *PROJECTION(gn_sinu) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; diff --git a/src/PJ_gnom.cpp b/src/PJ_gnom.cpp index 27e5f925..a4b5e35d 100644 --- a/src/PJ_gnom.cpp +++ b/src/PJ_gnom.cpp @@ -125,7 +125,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(gnom) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_goode.cpp b/src/PJ_goode.cpp index 14c78439..c79d125e 100644 --- a/src/PJ_goode.cpp +++ b/src/PJ_goode.cpp @@ -50,9 +50,9 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; - if (0==P->opaque) + if (nullptr==P) + return nullptr; + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_free (static_cast<struct pj_opaque*>(P->opaque)->sinu); pj_free (static_cast<struct pj_opaque*>(P->opaque)->moll); @@ -63,13 +63,13 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ PJ *PROJECTION(goode) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; P->es = 0.; - if (!(Q->sinu = pj_sinu(0)) || !(Q->moll = pj_moll(0))) + if (!(Q->sinu = pj_sinu(nullptr)) || !(Q->moll = pj_moll(nullptr))) return destructor (P, ENOMEM); Q->sinu->es = 0.; Q->sinu->ctx = P->ctx; diff --git a/src/PJ_gstmerc.cpp b/src/PJ_gstmerc.cpp index 01ef796d..9b819bac 100644 --- a/src/PJ_gstmerc.cpp +++ b/src/PJ_gstmerc.cpp @@ -54,7 +54,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(gstmerc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_hammer.cpp b/src/PJ_hammer.cpp index 974bc813..d4caa656 100644 --- a/src/PJ_hammer.cpp +++ b/src/PJ_hammer.cpp @@ -51,7 +51,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(hammer) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_healpix.cpp b/src/PJ_healpix.cpp index 64b57a26..7f0b3e83 100644 --- a/src/PJ_healpix.cpp +++ b/src/PJ_healpix.cpp @@ -605,10 +605,10 @@ static LP e_rhealpix_inverse(XY xy, PJ *P) { /* ellipsoid */ static PJ *destructor (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->apa); @@ -618,14 +618,14 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor PJ *PROJECTION(healpix) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; if (P->es != 0.0) { Q->apa = pj_authset(P->es); /* For auth_lat(). */ - if (0==Q->apa) + if (nullptr==Q->apa) return destructor(P, ENOMEM); Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */ P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */ @@ -643,7 +643,7 @@ PJ *PROJECTION(healpix) { PJ *PROJECTION(rhealpix) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -658,7 +658,7 @@ PJ *PROJECTION(rhealpix) { return destructor (P, PJD_ERR_AXIS); if (P->es != 0.0) { Q->apa = pj_authset(P->es); /* For auth_lat(). */ - if (0==Q->apa) + if (nullptr==Q->apa) return destructor(P, ENOMEM); Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */ P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */ diff --git a/src/PJ_helmert.cpp b/src/PJ_helmert.cpp index b2072a84..4a3abf4e 100644 --- a/src/PJ_helmert.cpp +++ b/src/PJ_helmert.cpp @@ -479,7 +479,7 @@ static PJ_COORD helmert_reverse_4d (PJ_COORD point, PJ *P) { static PJ* init_helmert_six_parameters(PJ* P) { struct pj_opaque_helmert *Q = static_cast<struct pj_opaque_helmert*>(pj_calloc (1, sizeof (struct pj_opaque_helmert))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = (void *) Q; @@ -560,7 +560,7 @@ PJ *TRANSFORMATION(helmert, 0) { struct pj_opaque_helmert *Q; if( !init_helmert_six_parameters(P) ) { - return 0; + return nullptr; } /* In the 2D case, the coordinates are projected */ @@ -663,7 +663,7 @@ PJ *TRANSFORMATION(helmert, 0) { } if( !read_convention(P) ) { - return 0; + return nullptr; } /* Let's help with debugging */ @@ -699,7 +699,7 @@ PJ *TRANSFORMATION(molobadekas, 0) { struct pj_opaque_helmert *Q; if( !init_helmert_six_parameters(P) ) { - return 0; + return nullptr; } P->fwd3d = helmert_forward_3d; @@ -716,7 +716,7 @@ PJ *TRANSFORMATION(molobadekas, 0) { Q->scale = Q->scale_0; if( !read_convention(P) ) { - return 0; + return nullptr; } /* Reference point */ diff --git a/src/PJ_hgridshift.cpp b/src/PJ_hgridshift.cpp index 9ed9ca02..f0e57251 100644 --- a/src/PJ_hgridshift.cpp +++ b/src/PJ_hgridshift.cpp @@ -21,7 +21,7 @@ static XYZ forward_3d(LPZ lpz, PJ *P) { PJ_COORD point = {{0,0,0,0}}; point.lpz = lpz; - if (P->gridlist != NULL) { + if (P->gridlist != nullptr) { /* Only try the gridshift if at least one grid is loaded, * otherwise just pass the coordinate through unchanged. */ point.lp = proj_hgrid_apply(P, point.lp, PJ_FWD); @@ -35,7 +35,7 @@ static LPZ reverse_3d(XYZ xyz, PJ *P) { PJ_COORD point = {{0,0,0,0}}; point.xyz = xyz; - if (P->gridlist != NULL) { + if (P->gridlist != nullptr) { /* Only try the gridshift if at least one grid is loaded, * otherwise just pass the coordinate through unchanged. */ point.lp = proj_hgrid_apply(P, point.lp, PJ_INV); @@ -82,7 +82,7 @@ static PJ_COORD reverse_4d(PJ_COORD obs, PJ *P) { PJ *TRANSFORMATION(hgridshift,0) { struct pj_opaque_hgridshift *Q = static_cast<struct pj_opaque_hgridshift*>(pj_calloc (1, sizeof (struct pj_opaque_hgridshift))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = (void *) Q; @@ -90,8 +90,8 @@ PJ *TRANSFORMATION(hgridshift,0) { P->inv4d = reverse_4d; P->fwd3d = forward_3d; P->inv3d = reverse_3d; - P->fwd = 0; - P->inv = 0; + P->fwd = nullptr; + P->inv = nullptr; P->left = PJ_IO_UNITS_ANGULAR; P->right = PJ_IO_UNITS_ANGULAR; diff --git a/src/PJ_horner.cpp b/src/PJ_horner.cpp index f2d8cb5a..3a1b7cca 100644 --- a/src/PJ_horner.cpp +++ b/src/PJ_horner.cpp @@ -143,8 +143,8 @@ static HORNER *horner_alloc (size_t order, int complex_polynomia) { int polynomia_ok = 0; HORNER *h = static_cast<HORNER*>(horner_calloc (1, sizeof (HORNER))); - if (0==h) - return 0; + if (nullptr==h) + return nullptr; if (complex_polynomia) n = 2*(int)order + 2; @@ -174,7 +174,7 @@ static HORNER *horner_alloc (size_t order, int complex_polynomia) { /* safe, since all pointers are null-initialized (by calloc) */ horner_free (h); - return 0; + return nullptr; } @@ -226,7 +226,7 @@ summing the tiny high order elements first. UV uv_error; uv_error.u = uv_error.v = HUGE_VAL; - if (0==transformation) + if (nullptr==transformation) return uv_error; /* Check for valid value of direction (-1, 0, 1) */ @@ -326,7 +326,7 @@ polynomial evaluation engine. UV uv_error; uv_error.u = uv_error.v = HUGE_VAL; - if (0==transformation) + if (nullptr==transformation) return uv_error; /* Check for valid value of direction (-1, 0, 1) */ @@ -398,22 +398,22 @@ static PJ_COORD complex_horner_reverse_4d (PJ_COORD point, PJ *P) { static PJ *horner_freeup (PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; - if (0==P->opaque) + if (nullptr==P) + return nullptr; + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); horner_free ((HORNER *) P->opaque); - P->opaque = 0; + P->opaque = nullptr; return pj_default_destructor (P, errlev); } static int parse_coefs (PJ *P, double *coefs, char *param, int ncoefs) { - char *buf, *init, *next = 0; + char *buf, *init, *next = nullptr; int i; buf = static_cast<char*>(pj_calloc (strlen (param) + 2, sizeof(char))); - if (0==buf) { + if (nullptr==buf) { proj_log_error (P, "Horner: No memory left"); return 0; } @@ -429,7 +429,7 @@ static int parse_coefs (PJ *P, double *coefs, char *param, int ncoefs) { for (i = 0; i < ncoefs; i++) { if (i > 0) { - if ( next == 0 || ','!=*next) { + if ( next == nullptr || ','!=*next) { proj_log_error (P, "Horner: Malformed polynomium set %s. need %d coefs", param, ncoefs); return 0; } @@ -448,10 +448,10 @@ PJ *PROJECTION(horner) { HORNER *Q; P->fwd4d = horner_forward_4d; P->inv4d = horner_reverse_4d; - P->fwd3d = 0; - P->inv3d = 0; - P->fwd = 0; - P->inv = 0; + P->fwd3d = nullptr; + P->inv3d = nullptr; + P->fwd = nullptr; + P->inv = nullptr; P->left = P->right = PJ_IO_UNITS_PROJECTED; P->destructor = horner_freeup; @@ -472,7 +472,7 @@ PJ *PROJECTION(horner) { complex_polynomia = 1; Q = horner_alloc (degree, complex_polynomia); - if (Q == 0) + if (Q == nullptr) return horner_freeup (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_igh.cpp b/src/PJ_igh.cpp index 60f5a4e8..e3576861 100644 --- a/src/PJ_igh.cpp +++ b/src/PJ_igh.cpp @@ -138,10 +138,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ static PJ *destructor (PJ *P, int errlev) { int i; - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); for (i = 0; i < 12; ++i) { @@ -175,7 +175,7 @@ static PJ *destructor (PJ *P, int errlev) { */ #define SETUP(n, proj, x_0, y_0, lon_0) \ - if (!(Q->pj[n-1] = pj_##proj(0))) return destructor(P, ENOMEM); \ + if (!(Q->pj[n-1] = pj_##proj(nullptr))) return destructor(P, ENOMEM); \ if (!(Q->pj[n-1] = pj_##proj(Q->pj[n-1]))) return destructor(P, ENOMEM); \ Q->pj[n-1]->ctx = P->ctx; \ Q->pj[n-1]->x0 = x_0; \ @@ -187,7 +187,7 @@ PJ *PROJECTION(igh) { XY xy1, xy3; LP lp = { 0, d4044118 }; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_imw_p.cpp b/src/PJ_imw_p.cpp index a6e9d0bb..012c5caa 100644 --- a/src/PJ_imw_p.cpp +++ b/src/PJ_imw_p.cpp @@ -143,10 +143,10 @@ static void xy(PJ *P, double phi, double *x, double *y, double *sp, double *R) { static PJ *destructor (PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); if( static_cast<struct pj_opaque*>(P->opaque)->en ) @@ -160,7 +160,7 @@ PJ *PROJECTION(imw_p) { double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2; int err; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_isea.cpp b/src/PJ_isea.cpp index cc0ddf9e..522e6813 100644 --- a/src/PJ_isea.cpp +++ b/src/PJ_isea.cpp @@ -1016,7 +1016,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(isea) { char *opt; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_krovak.cpp b/src/PJ_krovak.cpp index 7728002a..9ecffb89 100644 --- a/src/PJ_krovak.cpp +++ b/src/PJ_krovak.cpp @@ -179,7 +179,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ *PROJECTION(krovak) { double u0, n0, g; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_labrd.cpp b/src/PJ_labrd.cpp index c72aeb93..d3930243 100644 --- a/src/PJ_labrd.cpp +++ b/src/PJ_labrd.cpp @@ -103,7 +103,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ *PROJECTION(labrd) { double Az, sinp, R, N, t; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_laea.cpp b/src/PJ_laea.cpp index f1626a55..dd02c75a 100644 --- a/src/PJ_laea.cpp +++ b/src/PJ_laea.cpp @@ -227,10 +227,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ static PJ *destructor (PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->apa); @@ -242,7 +242,7 @@ static PJ *destructor (PJ *P, int errlev) { PJ *PROJECTION(laea) { double t; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; P->destructor = destructor; @@ -261,7 +261,7 @@ PJ *PROJECTION(laea) { Q->qp = pj_qsfn(1., P->e, P->one_es); Q->mmf = .5 / (1. - P->es); Q->apa = pj_authset(P->es); - if (0==Q->apa) + if (nullptr==Q->apa) return destructor(P, ENOMEM); switch (Q->mode) { case N_POLE: diff --git a/src/PJ_lagrng.cpp b/src/PJ_lagrng.cpp index 30306db4..8c0150aa 100644 --- a/src/PJ_lagrng.cpp +++ b/src/PJ_lagrng.cpp @@ -72,7 +72,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(lagrng) { double phi1; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_lcc.cpp b/src/PJ_lcc.cpp index 9483c085..7d6e3f57 100644 --- a/src/PJ_lcc.cpp +++ b/src/PJ_lcc.cpp @@ -82,7 +82,7 @@ PJ *PROJECTION(lcc) { int secant; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc(1, sizeof (struct pj_opaque))); - if (0 == Q) + if (nullptr == Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_lcca.cpp b/src/PJ_lcca.cpp index add6dcc7..70b5dff9 100644 --- a/src/PJ_lcca.cpp +++ b/src/PJ_lcca.cpp @@ -121,10 +121,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ static PJ *destructor (PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -135,7 +135,7 @@ static PJ *destructor (PJ *P, int errlev) { PJ *PROJECTION(lcca) { double s2p0, N0, R0, tan0; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_loxim.cpp b/src/PJ_loxim.cpp index fc412997..f68e844a 100644 --- a/src/PJ_loxim.cpp +++ b/src/PJ_loxim.cpp @@ -57,7 +57,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(loxim) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_lsat.cpp b/src/PJ_lsat.cpp index ba829d42..a0eca1bd 100644 --- a/src/PJ_lsat.cpp +++ b/src/PJ_lsat.cpp @@ -156,7 +156,7 @@ PJ *PROJECTION(lsat) { int land, path; double lam, alf, esc, ess; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_misrsom.cpp b/src/PJ_misrsom.cpp index 3d8adbe9..c84b96e3 100644 --- a/src/PJ_misrsom.cpp +++ b/src/PJ_misrsom.cpp @@ -173,7 +173,7 @@ PJ *PROJECTION(misrsom) { double lam, alf, esc, ess; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_mod_ster.cpp b/src/PJ_mod_ster.cpp index 7ef34f0a..7c4f363b 100644 --- a/src/PJ_mod_ster.cpp +++ b/src/PJ_mod_ster.cpp @@ -130,7 +130,7 @@ PJ *PROJECTION(mil_os) { }; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -153,7 +153,7 @@ PJ *PROJECTION(lee_os) { }; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -178,7 +178,7 @@ PJ *PROJECTION(gs48) { }; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -213,7 +213,7 @@ PJ *PROJECTION(alsk) { }; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -261,7 +261,7 @@ PJ *PROJECTION(gs50) { }; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_moll.cpp b/src/PJ_moll.cpp index aed16132..c877a1bb 100644 --- a/src/PJ_moll.cpp +++ b/src/PJ_moll.cpp @@ -77,7 +77,7 @@ static PJ * setup(PJ *P, double p) { PJ *PROJECTION(moll) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -87,7 +87,7 @@ PJ *PROJECTION(moll) { PJ *PROJECTION(wag4) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -96,7 +96,7 @@ PJ *PROJECTION(wag4) { PJ *PROJECTION(wag5) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_molodensky.cpp b/src/PJ_molodensky.cpp index 6ed8dd33..91743fda 100644 --- a/src/PJ_molodensky.cpp +++ b/src/PJ_molodensky.cpp @@ -276,7 +276,7 @@ static PJ_COORD reverse_4d(PJ_COORD obs, PJ *P) { PJ *TRANSFORMATION(molodensky,1) { int count_required_params = 0; struct pj_opaque_molodensky *Q = static_cast<struct pj_opaque_molodensky*>(pj_calloc(1, sizeof(struct pj_opaque_molodensky))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = (void *) Q; diff --git a/src/PJ_nsper.cpp b/src/PJ_nsper.cpp index beace3d9..f93010f8 100644 --- a/src/PJ_nsper.cpp +++ b/src/PJ_nsper.cpp @@ -173,7 +173,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(nsper) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -187,7 +187,7 @@ PJ *PROJECTION(tpers) { double omega, gamma; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_ob_tran.cpp b/src/PJ_ob_tran.cpp index ee1dc465..d34059a9 100644 --- a/src/PJ_ob_tran.cpp +++ b/src/PJ_ob_tran.cpp @@ -87,9 +87,9 @@ static LP t_inverse(XY xy, PJ *P) { /* spheroid */ static PJ *destructor(PJ *P, int errlev) { - if (0==P) - return 0; - if (0==P->opaque) + if (nullptr==P) + return nullptr; + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); if (static_cast<struct pj_opaque*>(P->opaque)->link) @@ -122,7 +122,7 @@ typedef struct {int argc; char **argv;} ARGS; /* count the number of args in the linked list <params> */ static size_t paralist_params_argc (paralist *params) { size_t argc = 0; - for (; params != 0; params = params->next) + for (; params != nullptr; params = params->next) argc++; return argc; } @@ -131,18 +131,18 @@ static size_t paralist_params_argc (paralist *params) { /* turn paralist into argc/argv style argument list */ static ARGS ob_tran_target_params (paralist *params) { int i = 0; - ARGS args = {0, 0}; + ARGS args = {0, nullptr}; size_t argc = paralist_params_argc (params); if (argc < 2) return args; /* all args except the proj_ob_tran */ args.argv = static_cast<char**>(pj_calloc (argc - 1, sizeof (char *))); - if (0==args.argv) + if (nullptr==args.argv) return args; /* Copy all args *except* the proj=ob_tran arg to the argv array */ - for (i = 0; params != 0; params = params->next) { + for (i = 0; params != nullptr; params = params->next) { if (0==strcmp (params->param, "proj=ob_tran")) continue; args.argv[i++] = params->param; @@ -169,7 +169,7 @@ PJ *PROJECTION(ob_tran) { PJ *R; /* projection to rotate */ struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return destructor(P, ENOMEM); P->opaque = Q; @@ -188,7 +188,7 @@ PJ *PROJECTION(ob_tran) { R = pj_init_ctx (pj_get_ctx(P), args.argc, args.argv); pj_dealloc (args.argv); - if (0==R) + if (nullptr==R) return destructor (P, PJD_ERR_UNKNOWN_PROJECTION_ID); Q->link = R; @@ -228,11 +228,11 @@ PJ *PROJECTION(ob_tran) { if (fabs(phip) > TOL) { /* oblique */ Q->cphip = cos(phip); Q->sphip = sin(phip); - P->fwd = Q->link->fwd ? o_forward : 0; - P->inv = Q->link->inv ? o_inverse : 0; + P->fwd = Q->link->fwd ? o_forward : nullptr; + P->inv = Q->link->inv ? o_inverse : nullptr; } else { /* transverse */ - P->fwd = Q->link->fwd ? t_forward : 0; - P->inv = Q->link->inv ? t_inverse : 0; + P->fwd = Q->link->fwd ? t_forward : nullptr; + P->inv = Q->link->inv ? t_inverse : nullptr; } /* Support some rather speculative test cases, where the rotated projection */ diff --git a/src/PJ_ocea.cpp b/src/PJ_ocea.cpp index 414c296f..0576ace7 100644 --- a/src/PJ_ocea.cpp +++ b/src/PJ_ocea.cpp @@ -54,7 +54,7 @@ PJ *PROJECTION(ocea) { double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_oea.cpp b/src/PJ_oea.cpp index 0b558f83..0c401b2f 100644 --- a/src/PJ_oea.cpp +++ b/src/PJ_oea.cpp @@ -60,7 +60,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(oea) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_omerc.cpp b/src/PJ_omerc.cpp index dbf90230..ead07128 100644 --- a/src/PJ_omerc.cpp +++ b/src/PJ_omerc.cpp @@ -123,7 +123,7 @@ PJ *PROJECTION(omerc) { int alp, gam, no_off = 0; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_ortho.cpp b/src/PJ_ortho.cpp index 4f5cf99a..6ea55248 100644 --- a/src/PJ_ortho.cpp +++ b/src/PJ_ortho.cpp @@ -122,7 +122,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(ortho) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_pipeline.cpp b/src/PJ_pipeline.cpp index bf28e93e..6d409690 100644 --- a/src/PJ_pipeline.cpp +++ b/src/PJ_pipeline.cpp @@ -211,14 +211,14 @@ static LP pipeline_reverse (XY xy, PJ *P) { static PJ *destructor (PJ *P, int errlev) { int i; - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); /* Deallocate each pipeine step, then pipeline array */ - if (0!=static_cast<struct pj_opaque*>(P->opaque)->pipeline) + if (nullptr!=static_cast<struct pj_opaque*>(P->opaque)->pipeline) for (i = 0; i < static_cast<struct pj_opaque*>(P->opaque)->steps; i++) proj_destroy (static_cast<struct pj_opaque*>(P->opaque)->pipeline[i+1]); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->pipeline); @@ -234,8 +234,8 @@ static PJ *pj_create_pipeline (PJ *P, size_t steps) { /* Room for the pipeline: An array of PJ * with room for sentinels at both ends */ static_cast<struct pj_opaque*>(P->opaque)->pipeline = static_cast<PJ**>(pj_calloc (steps + 2, sizeof(PJ *))); - if (0==static_cast<struct pj_opaque*>(P->opaque)->pipeline) - return 0; + if (nullptr==static_cast<struct pj_opaque*>(P->opaque)->pipeline) + return nullptr; static_cast<struct pj_opaque*>(P->opaque)->steps = (int)steps; @@ -248,7 +248,7 @@ static PJ *pj_create_pipeline (PJ *P, size_t steps) { /* count the number of args in pipeline definition, and mark all args as used */ static size_t argc_params (paralist *params) { size_t argc = 0; - for (; params != 0; params = params->next) { + for (; params != nullptr; params = params->next) { argc++; params->used = 1; } @@ -263,9 +263,9 @@ static char **argv_params (paralist *params, size_t argc) { char **argv; size_t i = 0; argv = static_cast<char**>(pj_calloc (argc, sizeof (char *))); - if (0==argv) - return 0; - for (; params != 0; params = params->next) + if (nullptr==argv) + return nullptr; + for (; params != nullptr; params = params->next) argv[i++] = params->param; argv[i++] = argv_sentinel; return argv; @@ -290,13 +290,13 @@ static void set_ellipsoid(PJ *P) { int err = proj_errno_reset (P); /* Break the linked list after the global args */ - attachment = 0; - for (cur = P->params; cur != 0; cur = cur->next) + attachment = nullptr; + for (cur = P->params; cur != nullptr; cur = cur->next) /* cur->next will always be non 0 given argv_sentinel presence, */ /* but this is far from being obvious for a static analyzer */ - if (cur->next != 0 && strcmp(argv_sentinel, cur->next->param) == 0) { + if (cur->next != nullptr && strcmp(argv_sentinel, cur->next->param) == 0) { attachment = cur->next; - cur->next = 0; + cur->next = nullptr; break; } @@ -322,7 +322,7 @@ static void set_ellipsoid(PJ *P) { /* Re-attach the dangling list */ /* Note: cur will always be non 0 given argv_sentinel presence, */ /* but this is far from being obvious for a static analyzer */ - if( cur != 0 ) + if( cur != nullptr ) cur->next = attachment; proj_errno_restore (P, err); } @@ -353,16 +353,16 @@ PJ *OPERATION(pipeline,0) { P->opaque = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof(struct pj_opaque))); - if (0==P->opaque) + if (nullptr==P->opaque) return destructor(P, ENOMEM); argc = (int)argc_params (P->params); static_cast<struct pj_opaque*>(P->opaque)->argv = argv = argv_params (P->params, argc); - if (0==argv) + if (nullptr==argv) return destructor (P, ENOMEM); static_cast<struct pj_opaque*>(P->opaque)->current_argv = current_argv = static_cast<char**>(pj_calloc (argc, sizeof (char *))); - if (0==current_argv) + if (nullptr==current_argv) return destructor (P, ENOMEM); /* Do some syntactical sanity checking */ @@ -396,7 +396,7 @@ PJ *OPERATION(pipeline,0) { return destructor (P, PJD_ERR_MALFORMED_PIPELINE); /* ERROR: no pipeline def */ /* Make room for the pipeline and execution indicators */ - if (0==pj_create_pipeline (P, nsteps)) + if (nullptr==pj_create_pipeline (P, nsteps)) return destructor (P, ENOMEM); set_ellipsoid(P); @@ -407,7 +407,7 @@ PJ *OPERATION(pipeline,0) { int j; int current_argc = 0; int err; - PJ *next_step = 0; + PJ *next_step = nullptr; /* Build a set of setup args for the current step */ proj_log_trace (P, "Pipeline: Building arg list for step no. %d", i); @@ -431,7 +431,7 @@ PJ *OPERATION(pipeline,0) { next_step = proj_create_argv (P->ctx, current_argc, current_argv); proj_log_trace (P, "Pipeline: Step %d (%s) at %p", i, current_argv[0], next_step); - if (0==next_step) { + if (nullptr==next_step) { /* The step init failed, but possibly without setting errno. If so, we say "malformed" */ int err_to_report = proj_errno(P); if (0==err_to_report) @@ -472,9 +472,9 @@ PJ *OPERATION(pipeline,0) { if ( pj_has_inverse(Q) ) { continue; } else { - P->inv = 0; - P->inv3d = 0; - P->inv4d = 0; + P->inv = nullptr; + P->inv3d = nullptr; + P->inv4d = nullptr; break; } } diff --git a/src/PJ_poly.cpp b/src/PJ_poly.cpp index 9eb97467..a970fdb1 100644 --- a/src/PJ_poly.cpp +++ b/src/PJ_poly.cpp @@ -134,10 +134,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ static PJ *destructor(PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); if (static_cast<struct pj_opaque*>(P->opaque)->en) @@ -149,7 +149,7 @@ static PJ *destructor(PJ *P, int errlev) { PJ *PROJECTION(poly) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_putp3.cpp b/src/PJ_putp3.cpp index c55a1732..98bb2ff0 100644 --- a/src/PJ_putp3.cpp +++ b/src/PJ_putp3.cpp @@ -37,7 +37,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(putp3) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -52,7 +52,7 @@ PJ *PROJECTION(putp3) { PJ *PROJECTION(putp3p) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_putp4p.cpp b/src/PJ_putp4p.cpp index 2ad20d1b..608fc76e 100644 --- a/src/PJ_putp4p.cpp +++ b/src/PJ_putp4p.cpp @@ -44,7 +44,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(putp4p) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -61,7 +61,7 @@ PJ *PROJECTION(putp4p) { PJ *PROJECTION(weren) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_putp5.cpp b/src/PJ_putp5.cpp index 41849f33..79e2ad15 100644 --- a/src/PJ_putp5.cpp +++ b/src/PJ_putp5.cpp @@ -43,7 +43,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(putp5) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -60,7 +60,7 @@ PJ *PROJECTION(putp5) { PJ *PROJECTION(putp5p) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_putp6.cpp b/src/PJ_putp6.cpp index bfa7d908..1186b18b 100644 --- a/src/PJ_putp6.cpp +++ b/src/PJ_putp6.cpp @@ -59,7 +59,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(putp6) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -79,7 +79,7 @@ PJ *PROJECTION(putp6) { PJ *PROJECTION(putp6p) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_qsc.cpp b/src/PJ_qsc.cpp index bca7c4fb..b50a7c95 100644 --- a/src/PJ_qsc.cpp +++ b/src/PJ_qsc.cpp @@ -377,7 +377,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ *PROJECTION(qsc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_rpoly.cpp b/src/PJ_rpoly.cpp index a3b07c45..a34f6171 100644 --- a/src/PJ_rpoly.cpp +++ b/src/PJ_rpoly.cpp @@ -43,7 +43,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(rpoly) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_sch.cpp b/src/PJ_sch.cpp index 23b6c4c2..5a2f944b 100644 --- a/src/PJ_sch.cpp +++ b/src/PJ_sch.cpp @@ -195,7 +195,7 @@ static PJ *setup(PJ *P) { /* general initialization */ PJ *PROJECTION(sch) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_sconics.cpp b/src/PJ_sconics.cpp index 788bdb02..1d19a13d 100644 --- a/src/PJ_sconics.cpp +++ b/src/PJ_sconics.cpp @@ -117,7 +117,7 @@ static PJ *setup(PJ *P, enum Type type) { double del, cs; int err; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; Q->type = type; diff --git a/src/PJ_somerc.cpp b/src/PJ_somerc.cpp index b82f1a58..15d2e765 100644 --- a/src/PJ_somerc.cpp +++ b/src/PJ_somerc.cpp @@ -72,7 +72,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ *PROJECTION(somerc) { double cp, phip0, sp; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_stere.cpp b/src/PJ_stere.cpp index 58d5858d..1502b2a6 100644 --- a/src/PJ_stere.cpp +++ b/src/PJ_stere.cpp @@ -286,7 +286,7 @@ static PJ *setup(PJ *P) { /* general initialization */ PJ *PROJECTION(stere) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -299,7 +299,7 @@ PJ *PROJECTION(stere) { PJ *PROJECTION(ups) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_sterea.cpp b/src/PJ_sterea.cpp index 05a6e5e3..bb498068 100644 --- a/src/PJ_sterea.cpp +++ b/src/PJ_sterea.cpp @@ -81,10 +81,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ static PJ *destructor (PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -96,12 +96,12 @@ PJ *PROJECTION(sterea) { double R; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; Q->en = pj_gauss_ini(P->e, P->phi0, &(Q->phic0), &R); - if (0==Q->en) + if (nullptr==Q->en) return pj_default_destructor (P, ENOMEM); Q->sinc0 = sin (Q->phic0); diff --git a/src/PJ_sts.cpp b/src/PJ_sts.cpp index bc56ed81..9f889611 100644 --- a/src/PJ_sts.cpp +++ b/src/PJ_sts.cpp @@ -71,7 +71,7 @@ static PJ *setup(PJ *P, double p, double q, int mode) { PJ *PROJECTION(fouc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; return setup(P, 2., 2., 1); @@ -81,7 +81,7 @@ PJ *PROJECTION(fouc) { PJ *PROJECTION(kav5) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -92,7 +92,7 @@ PJ *PROJECTION(kav5) { PJ *PROJECTION(qua_aut) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; return setup(P, 2., 2., 0); @@ -102,7 +102,7 @@ PJ *PROJECTION(qua_aut) { PJ *PROJECTION(mbt_s) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; return setup(P, 1.48875, 1.36509, 0); diff --git a/src/PJ_tcc.cpp b/src/PJ_tcc.cpp index 60ded63e..64fdc182 100644 --- a/src/PJ_tcc.cpp +++ b/src/PJ_tcc.cpp @@ -28,7 +28,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(tcc) { P->es = 0.; P->fwd = s_forward; - P->inv = 0; + P->inv = nullptr; return P; } diff --git a/src/PJ_tmerc.cpp b/src/PJ_tmerc.cpp index ac6319ff..5a2dacbd 100644 --- a/src/PJ_tmerc.cpp +++ b/src/PJ_tmerc.cpp @@ -167,10 +167,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ static PJ *destructor(PJ *P, int errlev) { /* Destructor */ - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor(P, errlev); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)->en); @@ -200,7 +200,7 @@ static PJ *setup(PJ *P) { /* general initialization */ PJ *PROJECTION(tmerc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_tpeqd.cpp b/src/PJ_tpeqd.cpp index a1c049aa..2720327a 100644 --- a/src/PJ_tpeqd.cpp +++ b/src/PJ_tpeqd.cpp @@ -62,7 +62,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(tpeqd) { double lam_1, lam_2, phi_1, phi_2, A12, pp; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_unitconvert.cpp b/src/PJ_unitconvert.cpp index 09eb3ae8..f7545680 100644 --- a/src/PJ_unitconvert.cpp +++ b/src/PJ_unitconvert.cpp @@ -276,7 +276,7 @@ static const struct TIME_UNITS time_units[] = { {"decimalyear", decimalyear_to_mjd, mjd_to_decimalyear, "Decimal year"}, {"gps_week", gps_week_to_mjd, mjd_to_gps_week, "GPS Week"}, {"yyyymmdd", yyyymmdd_to_mjd, mjd_to_yyyymmdd, "YYYYMMDD date"}, - {NULL, NULL, NULL, NULL} + {nullptr, nullptr, nullptr, nullptr} }; @@ -424,7 +424,7 @@ static double get_unit_conversion_factor(const char* name, } } if( p_normalized_name ) { - *p_normalized_name = NULL; + *p_normalized_name = nullptr; } if( p_is_linear ) { *p_is_linear = -1; @@ -444,7 +444,7 @@ PJ *CONVERSION(unitconvert,0) { int z_in_is_linear = -1; /* unknown */ int z_out_is_linear = -1; /* unknown */ - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = (void *) Q; @@ -465,8 +465,8 @@ PJ *CONVERSION(unitconvert,0) { Q->xy_factor = 1.0; Q->z_factor = 1.0; - if ((name = pj_param (P->ctx, P->params, "sxy_in").s) != NULL) { - const char* normalized_name = NULL; + if ((name = pj_param (P->ctx, P->params, "sxy_in").s) != nullptr) { + const char* normalized_name = nullptr; f = get_unit_conversion_factor(name, &xy_in_is_linear, &normalized_name); if (f != 0.0) { proj_log_debug(P, "xy_in unit: %s", normalized_name); @@ -478,8 +478,8 @@ PJ *CONVERSION(unitconvert,0) { Q->xy_factor *= f; } - if ((name = pj_param (P->ctx, P->params, "sxy_out").s) != NULL) { - const char* normalized_name = NULL; + if ((name = pj_param (P->ctx, P->params, "sxy_out").s) != nullptr) { + const char* normalized_name = nullptr; f = get_unit_conversion_factor(name, &xy_out_is_linear, &normalized_name); if (f != 0.0) { proj_log_debug(P, "xy_out unit: %s", normalized_name); @@ -497,8 +497,8 @@ PJ *CONVERSION(unitconvert,0) { return pj_default_destructor(P, PJD_ERR_INCONSISTENT_UNIT); } - if ((name = pj_param (P->ctx, P->params, "sz_in").s) != NULL) { - const char* normalized_name = NULL; + if ((name = pj_param (P->ctx, P->params, "sz_in").s) != nullptr) { + const char* normalized_name = nullptr; f = get_unit_conversion_factor(name, &z_in_is_linear, &normalized_name); if (f != 0.0) { proj_log_debug(P, "z_in unit: %s", normalized_name); @@ -510,8 +510,8 @@ PJ *CONVERSION(unitconvert,0) { Q->z_factor *= f; } - if ((name = pj_param (P->ctx, P->params, "sz_out").s) != NULL) { - const char* normalized_name = NULL; + if ((name = pj_param (P->ctx, P->params, "sz_out").s) != nullptr) { + const char* normalized_name = nullptr; f = get_unit_conversion_factor(name, &z_out_is_linear, &normalized_name); if (f != 0.0) { proj_log_debug(P, "z_out unit: %s", normalized_name); @@ -529,7 +529,7 @@ PJ *CONVERSION(unitconvert,0) { return pj_default_destructor(P, PJD_ERR_INCONSISTENT_UNIT); } - if ((name = pj_param (P->ctx, P->params, "st_in").s) != NULL) { + if ((name = pj_param (P->ctx, P->params, "st_in").s) != nullptr) { for (i = 0; (s = time_units[i].id) && strcmp(name, s) ; ++i); if (!s) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); /* unknown unit conversion id */ @@ -538,8 +538,8 @@ PJ *CONVERSION(unitconvert,0) { proj_log_debug(P, "t_in unit: %s", time_units[i].name); } - s = 0; - if ((name = pj_param (P->ctx, P->params, "st_out").s) != NULL) { + s = nullptr; + if ((name = pj_param (P->ctx, P->params, "st_out").s) != nullptr) { for (i = 0; (s = time_units[i].id) && strcmp(name, s) ; ++i); if (!s) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); /* unknown unit conversion id */ diff --git a/src/PJ_urm5.cpp b/src/PJ_urm5.cpp index f16d1534..0e3c7e3c 100644 --- a/src/PJ_urm5.cpp +++ b/src/PJ_urm5.cpp @@ -31,7 +31,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(urm5) { double alpha, t; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -49,7 +49,7 @@ PJ *PROJECTION(urm5) { Q->rmn = 1. / (Q->m * Q->n); P->es = 0.; - P->inv = 0; + P->inv = nullptr; P->fwd = s_forward; return P; diff --git a/src/PJ_urmfps.cpp b/src/PJ_urmfps.cpp index 848ba4f9..7103222a 100644 --- a/src/PJ_urmfps.cpp +++ b/src/PJ_urmfps.cpp @@ -48,7 +48,7 @@ static PJ *setup(PJ *P) { PJ *PROJECTION(urmfps) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; @@ -67,7 +67,7 @@ PJ *PROJECTION(urmfps) { PJ *PROJECTION(wag1) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_vandg2.cpp b/src/PJ_vandg2.cpp index f414f1ef..61d50044 100644 --- a/src/PJ_vandg2.cpp +++ b/src/PJ_vandg2.cpp @@ -52,7 +52,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(vandg2) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; @@ -64,7 +64,7 @@ PJ *PROJECTION(vandg2) { PJ *PROJECTION(vandg3) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_vgridshift.cpp b/src/PJ_vgridshift.cpp index bf1300c7..b3da906d 100644 --- a/src/PJ_vgridshift.cpp +++ b/src/PJ_vgridshift.cpp @@ -23,7 +23,7 @@ static XYZ forward_3d(LPZ lpz, PJ *P) { PJ_COORD point = {{0,0,0,0}}; point.lpz = lpz; - if (P->vgridlist_geoid != NULL) { + if (P->vgridlist_geoid != nullptr) { /* Only try the gridshift if at least one grid is loaded, * otherwise just pass the coordinate through unchanged. */ point.xyz.z += Q->forward_multiplier * proj_vgrid_value(P, point.lp); @@ -38,7 +38,7 @@ static LPZ reverse_3d(XYZ xyz, PJ *P) { PJ_COORD point = {{0,0,0,0}}; point.xyz = xyz; - if (P->vgridlist_geoid != NULL) { + if (P->vgridlist_geoid != nullptr) { /* Only try the gridshift if at least one grid is loaded, * otherwise just pass the coordinate through unchanged. */ point.xyz.z -= Q->forward_multiplier * proj_vgrid_value(P, point.lp); @@ -86,7 +86,7 @@ static PJ_COORD reverse_4d(PJ_COORD obs, PJ *P) { PJ *TRANSFORMATION(vgridshift,0) { struct pj_opaque_vgridshift *Q = static_cast<struct pj_opaque_vgridshift*>(pj_calloc (1, sizeof (struct pj_opaque_vgridshift))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = (void *) Q; @@ -134,8 +134,8 @@ PJ *TRANSFORMATION(vgridshift,0) { P->inv4d = reverse_4d; P->fwd3d = forward_3d; P->inv3d = reverse_3d; - P->fwd = 0; - P->inv = 0; + P->fwd = nullptr; + P->inv = nullptr; P->left = PJ_IO_UNITS_ANGULAR; P->right = PJ_IO_UNITS_ANGULAR; diff --git a/src/PJ_wag3.cpp b/src/PJ_wag3.cpp index f0443688..bb1b4d49 100644 --- a/src/PJ_wag3.cpp +++ b/src/PJ_wag3.cpp @@ -35,7 +35,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(wag3) { double ts; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_wag7.cpp b/src/PJ_wag7.cpp index 2009e672..c8807f12 100644 --- a/src/PJ_wag7.cpp +++ b/src/PJ_wag7.cpp @@ -24,7 +24,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(wag7) { P->fwd = s_forward; - P->inv = 0; + P->inv = nullptr; P->es = 0.; return P; } diff --git a/src/PJ_wink1.cpp b/src/PJ_wink1.cpp index e466988f..de2f55ee 100644 --- a/src/PJ_wink1.cpp +++ b/src/PJ_wink1.cpp @@ -33,7 +33,7 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */ PJ *PROJECTION(wink1) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/PJ_wink2.cpp b/src/PJ_wink2.cpp index 3935372a..74a47283 100644 --- a/src/PJ_wink2.cpp +++ b/src/PJ_wink2.cpp @@ -43,13 +43,13 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ PJ *PROJECTION(wink2) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; static_cast<struct pj_opaque*>(P->opaque)->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f); P->es = 0.; - P->inv = 0; + P->inv = nullptr; P->fwd = s_forward; return P; diff --git a/src/cct.cpp b/src/cct.cpp index 0493e721..046257da 100644 --- a/src/cct.cpp +++ b/src/cct.cpp @@ -187,7 +187,7 @@ static void print(PJ_LOG_LEVEL log_level, const char *fmt, ...) { va_start( args, fmt ); msg_buf = (char *) malloc(100000); - if( msg_buf == NULL ) { + if( msg_buf == nullptr ) { va_end( args ); return; } @@ -216,7 +216,7 @@ int main(int argc, char **argv) { int decimals_angles = 10; int decimals_distances = 4; int columns_xyzt[] = {1, 2, 3, 4}; - const char *longflags[] = {"v=verbose", "h=help", "I=inverse", "version", 0}; + const char *longflags[] = {"v=verbose", "h=help", "I=inverse", "version", nullptr}; const char *longkeys[] = { "o=output", "c=columns", @@ -224,12 +224,12 @@ int main(int argc, char **argv) { "z=height", "t=time", "s=skip-lines", - 0}; + nullptr}; fout = stdout; o = opt_parse (argc, argv, "hvI", "cdozts", longflags, longkeys); - if (0==o) + if (nullptr==o) return 0; if (opt_given (o, "h") || argc==1) { @@ -250,7 +250,7 @@ int main(int argc, char **argv) { if (opt_given (o, "o")) fout = fopen (opt_arg (o, "output"), "wt"); - if (0==fout) { + if (nullptr==fout) { print (PJ_LOG_ERROR, "%s: Cannot open '%s' for output\n", o->progname, opt_arg (o, "output")); free (o); return 1; @@ -296,8 +296,8 @@ int main(int argc, char **argv) { } /* Setup transformation */ - P = proj_create_argv (0, o->pargc, o->pargv); - if ((0==P) || (0==o->pargc)) { + P = proj_create_argv (nullptr, o->pargc, o->pargv); + if ((nullptr==P) || (0==o->pargc)) { print (PJ_LOG_ERROR, "%s: Bad transformation arguments - (%s)\n '%s -h' for help\n", o->progname, pj_strerrno (proj_errno(P)), o->progname); free (o); @@ -324,7 +324,7 @@ int main(int argc, char **argv) { /* Allocate input buffer */ buf = static_cast<char*>(calloc (1, 10000)); - if (0==buf) { + if (nullptr==buf) { print (PJ_LOG_ERROR, "%s: Out of memory\n", o->progname); pj_free (P); free (o); @@ -340,7 +340,7 @@ int main(int argc, char **argv) { void *ret = fgets (buf, 10000, o->input); char *c = column (buf, 1); opt_eof_handler (o); - if (0==ret) { + if (nullptr==ret) { print (PJ_LOG_ERROR, "Read error in record %d\n", (int) o->record_index); continue; } diff --git a/src/emess.cpp b/src/emess.cpp index eb2ac9d6..144e9e23 100644 --- a/src/emess.cpp +++ b/src/emess.cpp @@ -29,11 +29,11 @@ emess(int code, const char *fmt, ...) { va_start(args, fmt); /* prefix program name, if given */ - if (fmt != NULL) + if (fmt != nullptr) (void)fprintf(stderr,"%s\n<%s>: ",pj_get_release(), emess_dat.Prog_name); /* print file name and line, if given */ - if (emess_dat.File_name != NULL && *emess_dat.File_name) { + if (emess_dat.File_name != nullptr && *emess_dat.File_name) { (void)fprintf(stderr,"while processing file: %s", emess_dat.File_name); if (emess_dat.File_line > 0) (void)fprintf(stderr,", line %d\n", emess_dat.File_line); diff --git a/src/geod.cpp b/src/geod.cpp index bb52818e..d7741679 100644 --- a/src/geod.cpp +++ b/src/geod.cpp @@ -17,7 +17,7 @@ tag = '#', /* beginning of line tag character */ pos_azi = 0, /* output azimuths as positive values */ inverse = 0; /* != 0 then inverse geodesic */ static char -*oform = (char *)0, /* output format for decimal degrees */ +*oform = (char *)nullptr, /* output format for decimal degrees */ *osform = "%.3f", /* output format for S */ pline[50], /* work string */ *usage = @@ -133,7 +133,7 @@ int main(int argc, char **argv) { FILE *fid; static int eargc = 0, c; - if ((emess_dat.Prog_name = strrchr(*argv,'/')) != NULL) ++emess_dat.Prog_name; + if ((emess_dat.Prog_name = strrchr(*argv,'/')) != nullptr) ++emess_dat.Prog_name; else emess_dat.Prog_name = *argv; inverse = ! strncmp(emess_dat.Prog_name, "inv", 3); if (argc <= 1 ) { @@ -223,7 +223,7 @@ noargument: emess(1,"missing argument for -%c",*arg); fid = stdin; emess_dat.File_name = "<stdin>"; } else { - if ((fid = fopen(*eargv, "r")) == NULL) { + if ((fid = fopen(*eargv, "r")) == nullptr) { emess(-2, *eargv, "input file"); continue; } @@ -232,7 +232,7 @@ noargument: emess(1,"missing argument for -%c",*arg); emess_dat.File_line = 0; process(fid); (void)fclose(fid); - emess_dat.File_name = (char *)0; + emess_dat.File_name = (char *)nullptr; } } exit(0); /* normal completion */ diff --git a/src/geod_set.cpp b/src/geod_set.cpp index b5bd0667..b9e9c42f 100644 --- a/src/geod_set.cpp +++ b/src/geod_set.cpp @@ -11,7 +11,7 @@ void geod_set(int argc, char **argv) { - paralist *start = 0, *curr; + paralist *start = nullptr, *curr; double es; char *name; int i; @@ -22,7 +22,7 @@ geod_set(int argc, char **argv) { start = curr = pj_mkparam(argv[0]); if (!curr) emess(1, "memory allocation failed"); - for (i = 1; curr != 0 && i < argc; ++i) { + for (i = 1; curr != nullptr && i < argc; ++i) { curr->next = pj_mkparam(argv[i]); if (!curr->next) emess(1, "memory allocation failed"); @@ -31,7 +31,7 @@ geod_set(int argc, char **argv) { /* set elliptical parameters */ if (pj_ell_set(pj_get_default_ctx(),start, &geod_a, &es)) emess(1,"ellipse setup failure"); /* set units */ - if ((name = pj_param(NULL,start, "sunits").s) != NULL) { + if ((name = pj_param(nullptr,start, "sunits").s) != nullptr) { const char *s; const struct PJ_UNITS *unit_list = proj_list_units(); for (i = 0; (s = unit_list[i].id) && strcmp(name, s) ; ++i) ; @@ -44,27 +44,27 @@ geod_set(int argc, char **argv) { geod_f = es/(1 + sqrt(1 - es)); geod_ini(); /* check if line or arc mode */ - if (pj_param(NULL,start, "tlat_1").i) { + if (pj_param(nullptr,start, "tlat_1").i) { double del_S; #undef f - phi1 = pj_param(NULL,start, "rlat_1").f; - lam1 = pj_param(NULL,start, "rlon_1").f; - if (pj_param(NULL,start, "tlat_2").i) { - phi2 = pj_param(NULL,start, "rlat_2").f; - lam2 = pj_param(NULL,start, "rlon_2").f; + phi1 = pj_param(nullptr,start, "rlat_1").f; + lam1 = pj_param(nullptr,start, "rlon_1").f; + if (pj_param(nullptr,start, "tlat_2").i) { + phi2 = pj_param(nullptr,start, "rlat_2").f; + lam2 = pj_param(nullptr,start, "rlon_2").f; geod_inv(); geod_pre(); - } else if ((geod_S = pj_param(NULL,start, "dS").f) != 0.) { - al12 = pj_param(NULL,start, "rA").f; + } else if ((geod_S = pj_param(nullptr,start, "dS").f) != 0.) { + al12 = pj_param(nullptr,start, "rA").f; geod_pre(); geod_for(); } else emess(1,"incomplete geodesic/arc info"); - if ((n_alpha = pj_param(NULL,start, "in_A").i) > 0) { - if ((del_alpha = pj_param(NULL,start, "rdel_A").f) == 0.0) + if ((n_alpha = pj_param(nullptr,start, "in_A").i) > 0) { + if ((del_alpha = pj_param(nullptr,start, "rdel_A").f) == 0.0) emess(1,"del azimuth == 0"); - } else if ((del_S = fabs(pj_param(NULL,start, "ddel_S").f)) != 0.) { + } else if ((del_S = fabs(pj_param(nullptr,start, "ddel_S").f)) != 0.) { n_S = (int)(geod_S / del_S + .5); - } else if ((n_S = pj_param(NULL,start, "in_S").i) <= 0) + } else if ((n_S = pj_param(nullptr,start, "in_S").i) <= 0) emess(1,"no interval divisor selected"); } /* free up linked list */ diff --git a/src/geodesic.cpp b/src/geodesic.cpp index 220dcd7f..badfc9fa 100644 --- a/src/geodesic.cpp +++ b/src/geodesic.cpp @@ -693,12 +693,12 @@ real geod_genposition(const struct geod_geodesicline* l, void geod_setdistance(struct geod_geodesicline* l, real s13) { l->s13 = s13; - l->a13 = geod_genposition(l, GEOD_NOFLAGS, l->s13, 0, 0, 0, 0, 0, 0, 0, 0); + l->a13 = geod_genposition(l, GEOD_NOFLAGS, l->s13, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); } static void geod_setarc(struct geod_geodesicline* l, real a13) { l->a13 = a13; l->s13 = NaN; - geod_genposition(l, GEOD_ARCMODE, l->a13, 0, 0, 0, &l->s13, 0, 0, 0, 0); + geod_genposition(l, GEOD_ARCMODE, l->a13, nullptr, nullptr, nullptr, &l->s13, nullptr, nullptr, nullptr, nullptr); } void geod_gensetdistance(struct geod_geodesicline* l, @@ -710,7 +710,7 @@ void geod_gensetdistance(struct geod_geodesicline* l, void geod_position(const struct geod_geodesicline* l, real s12, real* plat2, real* plon2, real* pazi2) { - geod_genposition(l, FALSE, s12, plat2, plon2, pazi2, 0, 0, 0, 0, 0); + geod_genposition(l, FALSE, s12, plat2, plon2, pazi2, nullptr, nullptr, nullptr, nullptr, nullptr); } real geod_gendirect(const struct geod_geodesic* g, @@ -742,7 +742,7 @@ void geod_direct(const struct geod_geodesic* g, real s12, real* plat2, real* plon2, real* pazi2) { geod_gendirect(g, lat1, lon1, azi1, GEOD_NOFLAGS, s12, plat2, plon2, pazi2, - 0, 0, 0, 0, 0); + nullptr, nullptr, nullptr, nullptr, nullptr); } static real geod_geninverse_int(const struct geod_geodesic* g, @@ -858,9 +858,9 @@ static real geod_geninverse_int(const struct geod_geodesic* g, sig12 = atan2(maxx((real)(0), csig1 * ssig2 - ssig1 * csig2), csig1 * csig2 + ssig1 * ssig2); Lengths(g, g->n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, - cbet1, cbet2, &s12x, &m12x, 0, - (outmask & GEOD_GEODESICSCALE) ? &M12 : 0, - (outmask & GEOD_GEODESICSCALE) ? &M21 : 0, + cbet1, cbet2, &s12x, &m12x, nullptr, + (outmask & GEOD_GEODESICSCALE) ? &M12 : nullptr, + (outmask & GEOD_GEODESICSCALE) ? &M21 : nullptr, Ca); /* Add the check for sig12 since zero length geodesics might yield m12 < * 0. Test case was @@ -983,9 +983,9 @@ static real geod_geninverse_int(const struct geod_geodesic* g, fabs(salp1 - salp1b) + (calp1 - calp1b) < tolb); } Lengths(g, eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, - cbet1, cbet2, &s12x, &m12x, 0, - (outmask & GEOD_GEODESICSCALE) ? &M12 : 0, - (outmask & GEOD_GEODESICSCALE) ? &M21 : 0, Ca); + cbet1, cbet2, &s12x, &m12x, nullptr, + (outmask & GEOD_GEODESICSCALE) ? &M12 : nullptr, + (outmask & GEOD_GEODESICSCALE) ? &M21 : nullptr, Ca); m12x *= g->b; s12x *= g->b; a12 = sig12 / degree; @@ -1115,9 +1115,9 @@ void geod_inverseline(struct geod_geodesicline* l, real lat1, real lon1, real lat2, real lon2, unsigned caps) { real salp1, calp1, - a12 = geod_geninverse_int(g, lat1, lon1, lat2, lon2, 0, - &salp1, &calp1, 0, 0, - 0, 0, 0, 0), + a12 = geod_geninverse_int(g, lat1, lon1, lat2, lon2, nullptr, + &salp1, &calp1, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr), azi1 = atan2dx(salp1, calp1); caps = caps ? caps : GEOD_DISTANCE_IN | GEOD_LONGITUDE; /* Ensure that a12 can be converted to a distance */ @@ -1129,7 +1129,7 @@ void geod_inverseline(struct geod_geodesicline* l, void geod_inverse(const struct geod_geodesic* g, real lat1, real lon1, real lat2, real lon2, real* ps12, real* pazi1, real* pazi2) { - geod_geninverse(g, lat1, lon1, lat2, lon2, ps12, pazi1, pazi2, 0, 0, 0, 0); + geod_geninverse(g, lat1, lon1, lat2, lon2, ps12, pazi1, pazi2, nullptr, nullptr, nullptr, nullptr); } real SinCosSeries(boolx sinp, real sinx, real cosx, const real c[], int n) { @@ -1371,7 +1371,7 @@ real InverseStart(const struct geod_geodesic* g, * Inverse. */ Lengths(g, g->n, pi + bet12a, sbet1, -cbet1, dn1, sbet2, cbet2, dn2, - cbet1, cbet2, 0, &m12b, &m0, 0, 0, Ca); + cbet1, cbet2, nullptr, &m12b, &m0, nullptr, nullptr, Ca); x = -1 + m12b / (cbet1 * cbet2 * m0 * pi); betscale = x < -(real)(0.01) ? sbet12a / x : -g->f * sq(cbet1) * pi; @@ -1531,7 +1531,7 @@ real Lambda12(const struct geod_geodesic* g, dlam12 = - 2 * g->f1 * dn1 / sbet1; else { Lengths(g, eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, - cbet1, cbet2, 0, &dlam12, 0, 0, 0, Ca); + cbet1, cbet2, nullptr, &dlam12, nullptr, nullptr, nullptr, Ca); dlam12 *= g->f1 / (calp2 * cbet2); } } @@ -1819,7 +1819,7 @@ int transit(real lon1, real lon2) { /* Compute lon12 the same way as Geodesic::Inverse. */ lon1 = AngNormalize(lon1); lon2 = AngNormalize(lon2); - lon12 = AngDiff(lon1, lon2, 0); + lon12 = AngDiff(lon1, lon2, nullptr); return lon1 <= 0 && lon2 > 0 && lon12 > 0 ? 1 : (lon2 <= 0 && lon1 > 0 && lon12 < 0 ? -1 : 0); } @@ -1893,7 +1893,7 @@ void geod_polygon_addpoint(const struct geod_geodesic* g, } else { real s12, S12 = 0; /* Initialize S12 to stop Visual Studio warning */ geod_geninverse(g, p->lat, p->lon, lat, lon, - &s12, 0, 0, 0, 0, 0, p->polyline ? 0 : &S12); + &s12, nullptr, nullptr, nullptr, nullptr, nullptr, p->polyline ? nullptr : &S12); accadd(p->P, s12); if (!p->polyline) { accadd(p->A, S12); @@ -1912,8 +1912,8 @@ void geod_polygon_addedge(const struct geod_geodesic* g, * lon is to make CLang static analyzer happy. */ real lat = 0, lon = 0, S12 = 0; geod_gendirect(g, p->lat, p->lon, azi, GEOD_LONG_UNROLL, s, - &lat, &lon, 0, - 0, 0, 0, 0, p->polyline ? 0 : &S12); + &lat, &lon, nullptr, + nullptr, nullptr, nullptr, nullptr, p->polyline ? nullptr : &S12); accadd(p->P, s); if (!p->polyline) { accadd(p->A, S12); @@ -1940,7 +1940,7 @@ unsigned geod_polygon_compute(const struct geod_geodesic* g, return p->num; } geod_geninverse(g, p->lat, p->lon, p->lat0, p->lon0, - &s12, 0, 0, 0, 0, 0, &S12); + &s12, nullptr, nullptr, nullptr, nullptr, nullptr, &S12); if (pP) *pP = accsum(p->P, s12); acccopy(p->A, t); accadd(t, S12); @@ -1989,7 +1989,7 @@ unsigned geod_polygon_testpoint(const struct geod_geodesic* g, geod_geninverse(g, i == 0 ? p->lat : lat, i == 0 ? p->lon : lon, i != 0 ? p->lat0 : lat, i != 0 ? p->lon0 : lon, - &s12, 0, 0, 0, 0, 0, p->polyline ? 0 : &S12); + &s12, nullptr, nullptr, nullptr, nullptr, nullptr, p->polyline ? nullptr : &S12); perimeter += s12; if (!p->polyline) { tempsum += S12; @@ -2051,12 +2051,12 @@ unsigned geod_polygon_testedge(const struct geod_geodesic* g, happy. */ real lat = 0, lon = 0, s12, S12 = 0; geod_gendirect(g, p->lat, p->lon, azi, GEOD_LONG_UNROLL, s, - &lat, &lon, 0, - 0, 0, 0, 0, &S12); + &lat, &lon, nullptr, + nullptr, nullptr, nullptr, nullptr, &S12); tempsum += S12; crossings += transitdirect(p->lon, lon); geod_geninverse(g, lat, lon, p->lat0, p->lon0, - &s12, 0, 0, 0, 0, 0, &S12); + &s12, nullptr, nullptr, nullptr, nullptr, nullptr, &S12); perimeter += s12; tempsum += S12; crossings += transit(lon, p->lon0); diff --git a/src/geodtest.cpp b/src/geodtest.cpp index 0ee86d5c..6b3ea8b2 100644 --- a/src/geodtest.cpp +++ b/src/geodtest.cpp @@ -157,7 +157,7 @@ static int testdirect() { s12 = testcases[i][6]; a12 = testcases[i][7]; m12 = testcases[i][8]; M12 = testcases[i][9]; M21 = testcases[i][10]; S12 = testcases[i][11]; a12a = geod_gendirect(&g, lat1, lon1, azi1, flags, s12, - &lat2a, &lon2a, &azi2a, 0, + &lat2a, &lon2a, &azi2a, nullptr, &m12a, &M12a, &M21a, &S12a); result += checkEquals(lat2, lat2a, 1e-13); result += checkEquals(lon2, lon2a, 1e-13); @@ -246,7 +246,7 @@ static int GeodSolve4() { int result = 0; geod_init(&g, wgs84_a, wgs84_f); geod_inverse(&g, 36.493349428792, 0, 36.49334942879201, .0000008, - &s12, 0, 0); + &s12, nullptr, nullptr); result += checkEquals(s12, 0.072, 0.5e-3); return result; } @@ -277,13 +277,13 @@ static int GeodSolve6() { int result = 0; geod_init(&g, wgs84_a, wgs84_f); geod_inverse(&g, 88.202499451857, 0, - -88.202499451857, 179.981022032992859592, &s12, 0, 0); + -88.202499451857, 179.981022032992859592, &s12, nullptr, nullptr); result += checkEquals(s12, 20003898.214, 0.5e-3); geod_inverse(&g, 89.262080389218, 0, - -89.262080389218, 179.992207982775375662, &s12, 0, 0); + -89.262080389218, 179.992207982775375662, &s12, nullptr, nullptr); result += checkEquals(s12, 20003925.854, 0.5e-3); geod_inverse(&g, 89.333123580033, 0, - -89.333123580032997687, 179.99295812360148422, &s12, 0, 0); + -89.333123580032997687, 179.99295812360148422, &s12, nullptr, nullptr); result += checkEquals(s12, 20003926.881, 0.5e-3); return result; } @@ -295,7 +295,7 @@ static int GeodSolve9() { int result = 0; geod_init(&g, wgs84_a, wgs84_f); geod_inverse(&g, 56.320923501171, 0, - -56.320923501171, 179.664747671772880215, &s12, 0, 0); + -56.320923501171, 179.664747671772880215, &s12, nullptr, nullptr); result += checkEquals(s12, 19993558.287, 0.5e-3); return result; } @@ -308,7 +308,7 @@ static int GeodSolve10() { int result = 0; geod_init(&g, wgs84_a, wgs84_f); geod_inverse(&g, 52.784459512564, 0, - -52.784459512563990912, 179.634407464943777557, &s12, 0, 0); + -52.784459512563990912, 179.634407464943777557, &s12, nullptr, nullptr); result += checkEquals(s12, 19991596.095, 0.5e-3); return result; } @@ -321,7 +321,7 @@ static int GeodSolve11() { int result = 0; geod_init(&g, wgs84_a, wgs84_f); geod_inverse(&g, 48.522876735459, 0, - -48.52287673545898293, 179.599720456223079643, &s12, 0, 0); + -48.52287673545898293, 179.599720456223079643, &s12, nullptr, nullptr); result += checkEquals(s12, 19989144.774, 0.5e-3); return result; } @@ -367,7 +367,7 @@ static int GeodSolve15() { int result = 0; geod_init(&g, 6.4e6, -1/150.0); geod_gendirect(&g, 1, 2, 3, 0, 4, - 0, 0, 0, 0, 0, 0, 0, &S12); + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &S12); result += checkEquals(S12, 23700, 0.5); return result; } @@ -381,12 +381,12 @@ static int GeodSolve17() { unsigned flags = GEOD_LONG_UNROLL; geod_init(&g, wgs84_a, wgs84_f); geod_gendirect(&g, 40, -75, -10, flags, 2e7, - &lat2, &lon2, &azi2, 0, 0, 0, 0, 0); + &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(lat2, -39, 1); result += checkEquals(lon2, -254, 1); result += checkEquals(azi2, -170, 1); geod_lineinit(&l, &g, 40, -75, -10, 0); - geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0); + geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(lat2, -39, 1); result += checkEquals(lon2, -254, 1); result += checkEquals(azi2, -170, 1); @@ -407,7 +407,7 @@ static int GeodSolve26() { struct geod_geodesic g; int result = 0; geod_init(&g, 6.4e6, 0); - geod_geninverse(&g, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, &S12); + geod_geninverse(&g, 1, 2, 3, 4, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &S12); result += checkEquals(S12, 49911046115.0, 0.5); return result; } @@ -419,7 +419,7 @@ static int GeodSolve28() { struct geod_geodesic g; int result = 0; geod_init(&g, 6.4e6, 0.1); - a12 = geod_gendirect(&g, 1, 2, 10, 0, 5e6, 0, 0, 0, 0, 0, 0, 0, 0); + a12 = geod_gendirect(&g, 1, 2, 10, 0, 5e6, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(a12, 48.55570690, 0.5e-8); return result; } @@ -527,12 +527,12 @@ static int GeodSolve61() { unsigned flags = GEOD_LONG_UNROLL; geod_init(&g, wgs84_a, wgs84_f); geod_gendirect(&g, 45, 0, -0.000000000000000003, flags, 1e7, - &lat2, &lon2, &azi2, 0, 0, 0, 0, 0); + &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(lat2, 45.30632, 0.5e-5); result += checkEquals(lon2, -180, 0.5e-5); result += checkEquals(fabs(azi2), 180, 0.5e-5); geod_inverseline(&l, &g, 45, 0, 80, -0.000000000000000003, 0); - geod_genposition(&l, flags, 1e7, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0); + geod_genposition(&l, flags, 1e7, &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(lat2, 45.30632, 0.5e-5); result += checkEquals(lon2, -180, 0.5e-5); result += checkEquals(fabs(azi2), 180, 0.5e-5); @@ -585,11 +585,11 @@ static int GeodSolve67() { unsigned flags = GEOD_LONG_UNROLL; geod_init(&g, wgs84_a, wgs84_f); geod_inverseline(&l, &g, -5, -0.000000000000002, -10, 180, 0); - geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0); + geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(lat2, 4.96445, 0.5e-5); result += checkEquals(lon2, -180.00000, 0.5e-5); result += checkEquals(azi2, -0.00000, 0.5e-5); - geod_genposition(&l, flags, 0.5 * l.s13, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0); + geod_genposition(&l, flags, 0.5 * l.s13, &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkEquals(lat2, -87.52461, 0.5e-5); result += checkEquals(lon2, -0.00000, 0.5e-5); result += checkEquals(azi2, -180.00000, 0.5e-5); @@ -647,7 +647,7 @@ static void polylength(const struct geod_geodesic* g, geod_polygon_init(&p, 1); for (i = 0; i < N; ++i) geod_polygon_addpoint(g, &p, points[i][0], points[i][1]); - geod_polygon_compute(g, &p, 0, 1, 0, perimeter); + geod_polygon_compute(g, &p, 0, 1, nullptr, perimeter); } static int GeodSolve74() { @@ -707,10 +707,10 @@ static int GeodSolve80() { struct geod_geodesicline l; int result = 0; geod_init(&g, wgs84_a, wgs84_f); - geod_geninverse(&g, 0, 0, 0, 90, 0, 0, 0, 0, &M12, &M21, 0); + geod_geninverse(&g, 0, 0, 0, 90, nullptr, nullptr, nullptr, nullptr, &M12, &M21, nullptr); result += checkEquals(M12, -0.00528427534, 0.5e-10); result += checkEquals(M21, -0.00528427534, 0.5e-10); - geod_geninverse(&g, 0, 0, 1e-6, 1e-6, 0, 0, 0, 0, &M12, &M21, 0); + geod_geninverse(&g, 0, 0, 1e-6, 1e-6, nullptr, nullptr, nullptr, nullptr, &M12, &M21, nullptr); result += checkEquals(M12, 1, 0.5e-10); result += checkEquals(M21, 1, 0.5e-10); a12 = geod_geninverse(&g, 20.001, 0, 20.001, 0, @@ -735,7 +735,7 @@ static int GeodSolve80() { result += checkEquals(S12, 127516405431022, 0.5); /* An incapable line which can't take distance as input */ geod_lineinit(&l, &g, 1, 2, 90, GEOD_LATITUDE); - a12 = geod_genposition(&l, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0); + a12 = geod_genposition(&l, 0, 1000, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); result += checkNaN(a12); return result; } @@ -853,33 +853,33 @@ static int Planimeter15() { geod_polygon_init(&p, 0); geod_polygon_addpoint(&g, &p, lat[0], lon[0]); geod_polygon_addpoint(&g, &p, lat[1], lon[1]); - geod_polygon_testpoint(&g, &p, lat[2], lon[2], 0, 1, &area, 0); + geod_polygon_testpoint(&g, &p, lat[2], lon[2], 0, 1, &area, nullptr); result += checkEquals(area, r, 0.5); - geod_polygon_testpoint(&g, &p, lat[2], lon[2], 0, 0, &area, 0); + geod_polygon_testpoint(&g, &p, lat[2], lon[2], 0, 0, &area, nullptr); result += checkEquals(area, r, 0.5); - geod_polygon_testpoint(&g, &p, lat[2], lon[2], 1, 1, &area, 0); + geod_polygon_testpoint(&g, &p, lat[2], lon[2], 1, 1, &area, nullptr); result += checkEquals(area, -r, 0.5); - geod_polygon_testpoint(&g, &p, lat[2], lon[2], 1, 0, &area, 0); + geod_polygon_testpoint(&g, &p, lat[2], lon[2], 1, 0, &area, nullptr); result += checkEquals(area, a0-r, 0.5); - geod_inverse(&g, lat[1], lon[1], lat[2], lon[2], &s12, &azi1, 0); - geod_polygon_testedge(&g, &p, azi1, s12, 0, 1, &area, 0); + geod_inverse(&g, lat[1], lon[1], lat[2], lon[2], &s12, &azi1, nullptr); + geod_polygon_testedge(&g, &p, azi1, s12, 0, 1, &area, nullptr); result += checkEquals(area, r, 0.5); - geod_polygon_testedge(&g, &p, azi1, s12, 0, 0, &area, 0); + geod_polygon_testedge(&g, &p, azi1, s12, 0, 0, &area, nullptr); result += checkEquals(area, r, 0.5); - geod_polygon_testedge(&g, &p, azi1, s12, 1, 1, &area, 0); + geod_polygon_testedge(&g, &p, azi1, s12, 1, 1, &area, nullptr); result += checkEquals(area, -r, 0.5); - geod_polygon_testedge(&g, &p, azi1, s12, 1, 0, &area, 0); + geod_polygon_testedge(&g, &p, azi1, s12, 1, 0, &area, nullptr); result += checkEquals(area, a0-r, 0.5); geod_polygon_addpoint(&g, &p, lat[2], lon[2]); - geod_polygon_compute(&g, &p, 0, 1, &area, 0); + geod_polygon_compute(&g, &p, 0, 1, &area, nullptr); result += checkEquals(area, r, 0.5); - geod_polygon_compute(&g, &p, 0, 0, &area, 0); + geod_polygon_compute(&g, &p, 0, 0, &area, nullptr); result += checkEquals(area, r, 0.5); - geod_polygon_compute(&g, &p, 1, 1, &area, 0); + geod_polygon_compute(&g, &p, 1, 1, &area, nullptr); result += checkEquals(area, -r, 0.5); - geod_polygon_compute(&g, &p, 1, 0, &area, 0); + geod_polygon_compute(&g, &p, 1, 0, &area, nullptr); result += checkEquals(area, a0-r, 0.5); - geod_polygonarea(&g, lat, lon, 3, &area, 0); + geod_polygonarea(&g, lat, lon, 3, &area, nullptr); result += checkEquals(area, r, 0.5); return result; } @@ -907,14 +907,14 @@ static int Planimeter19() { result += area == 0 ? 0 : 1; result += perim == 0 ? 0 : 1; geod_polygon_init(&p, 1); - geod_polygon_compute(&g, &p, 0, 1, 0, &perim); + geod_polygon_compute(&g, &p, 0, 1, nullptr, &perim); result += perim == 0 ? 0 : 1; - geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, 0, &perim); + geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, nullptr, &perim); result += perim == 0 ? 0 : 1; - geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, 0, &perim); + geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, nullptr, &perim); result += checkNaN(perim); geod_polygon_addpoint(&g, &p, 1, 1); - geod_polygon_compute(&g, &p, 0, 1, 0, &perim); + geod_polygon_compute(&g, &p, 0, 1, nullptr, &perim); result += perim == 0 ? 0 : 1; return result; } @@ -944,30 +944,30 @@ static int Planimeter21() { for (i = 3; i <= 4; ++i) { geod_polygon_addpoint(&g, &p, lat, 60); geod_polygon_addpoint(&g, &p, lat, 180); - geod_polygon_testpoint(&g, &p, lat, -60, 0, 1, &area, 0); + geod_polygon_testpoint(&g, &p, lat, -60, 0, 1, &area, nullptr); if (i != 4) result += checkEquals(area, i*r, 0.5); - geod_polygon_testpoint(&g, &p, lat, -60, 0, 0, &area, 0); + geod_polygon_testpoint(&g, &p, lat, -60, 0, 0, &area, nullptr); if (i != 4) result += checkEquals(area, i*r, 0.5); - geod_polygon_testpoint(&g, &p, lat, -60, 1, 1, &area, 0); + geod_polygon_testpoint(&g, &p, lat, -60, 1, 1, &area, nullptr); if (i != 4) result += checkEquals(area, -i*r, 0.5); - geod_polygon_testpoint(&g, &p, lat, -60, 1, 0, &area, 0); + geod_polygon_testpoint(&g, &p, lat, -60, 1, 0, &area, nullptr); result += checkEquals(area, -i*r + a0, 0.5); - geod_polygon_testedge(&g, &p, a, s, 0, 1, &area, 0); + geod_polygon_testedge(&g, &p, a, s, 0, 1, &area, nullptr); if (i != 4) result += checkEquals(area, i*r, 0.5); - geod_polygon_testedge(&g, &p, a, s, 0, 0, &area, 0); + geod_polygon_testedge(&g, &p, a, s, 0, 0, &area, nullptr); if (i != 4) result += checkEquals(area, i*r, 0.5); - geod_polygon_testedge(&g, &p, a, s, 1, 1, &area, 0); + geod_polygon_testedge(&g, &p, a, s, 1, 1, &area, nullptr); if (i != 4) result += checkEquals(area, -i*r, 0.5); - geod_polygon_testedge(&g, &p, a, s, 1, 0, &area, 0); + geod_polygon_testedge(&g, &p, a, s, 1, 0, &area, nullptr); result += checkEquals(area, -i*r + a0, 0.5); geod_polygon_addpoint(&g, &p, lat, -60); - geod_polygon_compute(&g, &p, 0, 1, &area, 0); + geod_polygon_compute(&g, &p, 0, 1, &area, nullptr); if (i != 4) result += checkEquals(area, i*r, 0.5); - geod_polygon_compute(&g, &p, 0, 0, &area, 0); + geod_polygon_compute(&g, &p, 0, 0, &area, nullptr); if (i != 4) result += checkEquals(area, i*r, 0.5); - geod_polygon_compute(&g, &p, 1, 1, &area, 0); + geod_polygon_compute(&g, &p, 1, 1, &area, nullptr); if (i != 4) result += checkEquals(area, -i*r, 0.5); - geod_polygon_compute(&g, &p, 1, 0, &area, 0); + geod_polygon_compute(&g, &p, 1, 0, &area, nullptr); result += checkEquals(area, -i*r + a0, 0.5); } return result; @@ -985,7 +985,7 @@ static int AddEdge1() { geod_polygon_addedge(&g, &p, 90, 1000); geod_polygon_addedge(&g, &p, 0, 1000); geod_polygon_addedge(&g, &p, -90, 1000); - geod_polygon_compute(&g, &p, 0, 1, &area, 0); + geod_polygon_compute(&g, &p, 0, 1, &area, nullptr); result += checkEquals(area, 1000000.0, 0.01); return result; } @@ -1007,16 +1007,16 @@ static int EmptyPoly() { result += area == 0 ? 0 : 1; result += perim == 0 ? 0 : 1; geod_polygon_init(&p, 1); - geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, 0, &perim); + geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, nullptr, &perim); result += perim == 0 ? 0 : 1; - geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, 0, &perim); + geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, nullptr, &perim); result += checkNaN(perim); - geod_polygon_compute(&g, &p, 0, 1, 0, &perim); + geod_polygon_compute(&g, &p, 0, 1, nullptr, &perim); result += perim == 0 ? 0 : 1; geod_polygon_addpoint(&g, &p, 1, 1); - geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, 0, &perim); + geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, nullptr, &perim); result += checkEquals(perim, 1000, 1e-10); - geod_polygon_testpoint(&g, &p, 2, 2, 0, 1, 0, &perim); + geod_polygon_testpoint(&g, &p, 2, 2, 0, 1, nullptr, &perim); result += checkEquals(perim, 156876.149, 0.5e-3); return result; } diff --git a/src/gie.cpp b/src/gie.cpp index 77c21083..21a3a279 100644 --- a/src/gie.cpp +++ b/src/gie.cpp @@ -194,7 +194,7 @@ typedef struct { FILE *fout; } gie_ctx; -ffio *F = 0; +ffio *F = nullptr; static gie_ctx T; int tests=0, succs=0, succ_fails=0, fail_fails=0, succ_rtps=0, fail_rtps=0; @@ -236,8 +236,8 @@ static const char usage[] = { int main (int argc, char **argv) { int i; - const char *longflags[] = {"v=verbose", "q=quiet", "h=help", "l=list", "version", 0}; - const char *longkeys[] = {"o=output", 0}; + const char *longflags[] = {"v=verbose", "q=quiet", "h=help", "l=list", "version", nullptr}; + const char *longkeys[] = {"o=output", nullptr}; OPTARGS *o; memset (&T, 0, sizeof (T)); @@ -248,7 +248,7 @@ int main (int argc, char **argv) { T.use_proj4_init_rules = FALSE; o = opt_parse (argc, argv, "hlvq", "o", longflags, longkeys); - if (0==o) + if (nullptr==o) return 0; if (opt_given (o, "h") || argc==1) { @@ -274,7 +274,7 @@ int main (int argc, char **argv) { if (opt_given (o, "o")) T.fout = fopen (opt_arg (o, "output"), "rt"); - if (0==T.fout) { + if (nullptr==T.fout) { fprintf (stderr, "%s: Cannot open '%s' for output\n", o->progname, opt_arg (o, "output")); free (o); return 1; @@ -294,7 +294,7 @@ int main (int argc, char **argv) { } F = ffio_create (gie_tags, n_gie_tags, 1000); - if (0==F) { + if (nullptr==F) { fprintf (stderr, "%s: No memory\n", o->progname); free (o); return 1; @@ -379,12 +379,12 @@ static int process_file (const char *fname) { if (T.skip) { proj_destroy (T.P); - T.P = 0; + T.P = nullptr; return 0; } f = fopen (fname, "rt"); - if (0==f) { + if (nullptr==f) { if (T.verbosity > 0) { fprintf (T.fout, "%sCannot open spec'd input file '%s' - bye!\n", delim, fname); return 2; @@ -400,7 +400,7 @@ static int process_file (const char *fname) { while (get_inp(F)) { if (SKIP==dispatch (F->tag, F->args)) { proj_destroy (T.P); - T.P = 0; + T.P = nullptr; return 0; } } @@ -591,10 +591,10 @@ either a conversion or a transformation) if (T.P) proj_destroy (T.P); - proj_errno_reset (0); - proj_context_use_proj4_init_rules(0, T.use_proj4_init_rules); + proj_errno_reset (nullptr); + proj_context_use_proj4_init_rules(nullptr, T.use_proj4_init_rules); - T.P = proj_create (0, F->args); + T.P = proj_create (nullptr, F->args); /* Checking that proj_create succeeds is first done at "expect" time, */ /* since we want to support "expect"ing specific error codes */ @@ -715,7 +715,7 @@ Always returns 0. char *endp; PJ_COORD coo; - if (0==T.P) { + if (nullptr==T.P) { if (T.ignore == proj_errno(T.P)) return another_skip(); @@ -840,7 +840,7 @@ Tell GIE what to expect, when transforming the ACCEPTed input if (T.ignore==proj_errno(T.P)) return another_skip (); - if (0==T.P) { + if (nullptr==T.P) { /* If we expect failure, and fail, then it's a success... */ if (expect_failure) { /* Failed to fail correctly? */ @@ -1198,23 +1198,23 @@ static ffio *ffio_create (const char **tags, size_t n_tags, size_t max_record_si Constructor for the ffio object. ****************************************************************************************/ ffio *G = static_cast<ffio*>(calloc (1, sizeof (ffio))); - if (0==G) - return 0; + if (nullptr==G) + return nullptr; if (0==max_record_size) max_record_size = 1000; G->args = static_cast<char*>(calloc (1, 5*max_record_size)); - if (0==G->args) { + if (nullptr==G->args) { free (G); - return 0; + return nullptr; } G->next_args = static_cast<char*>(calloc (1, max_record_size)); - if (0==G->args) { + if (nullptr==G->args) { free (G->args); free (G); - return 0; + return nullptr; } G->args_size = 5*max_record_size; @@ -1238,7 +1238,7 @@ fclose has been called prior to ffio_destroy. free (G->args); free (G->next_args); free (G); - return 0; + return nullptr; } @@ -1255,10 +1255,10 @@ continues until a gie command verb is found at the start of a line ****************************************************************************************/ int i; char *c; - if (0==G) + if (nullptr==G) return 0; c = G->next_args; - if (0==c) + if (nullptr==c) return 0; if (0==c[0]) return 0; @@ -1279,7 +1279,7 @@ A start of a new command serves as an end delimiter for the current command for (j = 0; j < G->n_tags; j++) if (strncmp (G->next_args, G->tags[j], strlen(G->tags[j]))==0) return G->tags[j]; - return 0; + return nullptr; } @@ -1293,7 +1293,7 @@ instruction, or a "decorative element", i.e. one of the "ascii art" style block delimiters typically used to mark up block comments in a free format file. ****************************************************************************************/ - if (G==0) + if (G==nullptr) return 0; if (at_decorative_element (G)) return 1; @@ -1312,7 +1312,7 @@ Read next line of input file. Returns 1 on success, 0 on failure. G->next_args[0] = 0; if (T.skip) return 0; - if (0==fgets (G->next_args, (int) G->next_args_size - 1, G->f)) + if (nullptr==fgets (G->next_args, (int) G->next_args_size - 1, G->f)) return 0; if (feof (G->f)) return 0; @@ -1356,7 +1356,7 @@ Make sure we're inside a <gie>-block. Return 1 on success, 0 otherwise. G->next_args[0] = 0; if (feof (G->f)) return 0; - if (0==fgets (G->next_args, (int) G->next_args_size - 1, G->f)) + if (nullptr==fgets (G->next_args, (int) G->next_args_size - 1, G->f)) return 0; pj_chomp (G->next_args); G->next_lineno++; @@ -1415,7 +1415,7 @@ static int append_args (ffio *G) { /* +2: 1 for the space separator and 1 for the NUL termination. */ if (G->args_size < args_len + next_len - skip_chars + 2) { char *p = static_cast<char*>(realloc (G->args, 2 * G->args_size)); - if (0==p) + if (nullptr==p) return 0; G->args = p; G->args_size = 2 * G->args_size; @@ -1444,7 +1444,7 @@ whitespace etc. The block is stored in G->args. Returns 1 on success, 0 otherwis return 0; G->tag = at_tag (G); - if (0==G->tag) + if (nullptr==G->tag) return 0; do { diff --git a/src/mk_cheby.cpp b/src/mk_cheby.cpp index a2f90bef..5e6bfef0 100644 --- a/src/mk_cheby.cpp +++ b/src/mk_cheby.cpp @@ -23,36 +23,36 @@ makeT(int nru, int nrv) { int i; if (!(T = (Tseries *)pj_malloc(sizeof(Tseries)))) - return 0; + return nullptr; if (!(T->cu = (struct PW_COEF *)pj_malloc(sizeof(struct PW_COEF) * nru))) { pj_dalloc(T); - return 0; + return nullptr; } if (!(T->cv = (struct PW_COEF *)pj_malloc(sizeof(struct PW_COEF) * nrv))) { pj_dalloc(T->cu); pj_dalloc(T); - return 0; + return nullptr; } for (i = 0; i < nru; ++i) - T->cu[i].c = 0; + T->cu[i].c = nullptr; for (i = 0; i < nrv; ++i) - T->cv[i].c = 0; + T->cv[i].c = nullptr; return T; } Tseries * mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), int nu, int nv, int power) { int j, i, nru, nrv, *ncu, *ncv; - Tseries *T = NULL; + Tseries *T = nullptr; projUV **w; double cutres; if (!(w = (projUV **)vector2(nu, nv, sizeof(projUV)))) - return 0; + return nullptr; if (!(ncu = (int *)vector1(nu + nv, sizeof(int)))) { freev2((void **)w, nu); - return 0; + return nullptr; } ncv = ncu + nu; if (!bchgen(a, b, nu, nv, w, func)) { @@ -106,7 +106,7 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), if (ncu[j]) nru = j + 1; /* update row max */ if (ncv[j]) nrv = j + 1; } - if ((T = makeT(nru, nrv)) != NULL ) { + if ((T = makeT(nru, nrv)) != nullptr ) { T->a = a; T->b = b; T->mu = nru - 1; @@ -137,7 +137,7 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), } } } - } else if ((T = makeT(nru, nrv)) != NULL) { + } else if ((T = makeT(nru, nrv)) != nullptr) { /* else make returned Chebyshev coefficient structure */ T->mu = nru - 1; /* save row degree */ T->mv = nrv - 1; @@ -184,7 +184,7 @@ mk_cheby(projUV a, projUV b, double res, projUV *resid, projUV (*func)(projUV), pj_dalloc(T->cv[i].c); pj_dalloc(T); } - T = 0; + T = nullptr; gohome: freev2((void **) w, nu); pj_dalloc(ncu); diff --git a/src/multistresstest.cpp b/src/multistresstest.cpp index a6653e7e..234783b3 100644 --- a/src/multistresstest.cpp +++ b/src/multistresstest.cpp @@ -243,7 +243,7 @@ static void TestThread() dst_pj_list[i] = custom_pj_init_plus_ctx( ctx, test->dst_def ); { - int skipTest = (src_pj_list[i] == NULL || dst_pj_list[i] == NULL); + int skipTest = (src_pj_list[i] == nullptr || dst_pj_list[i] == nullptr); if ( skipTest != test->skip ) fprintf( stderr, "Threaded projection initialization does not match unthreaded initialization\n" ); @@ -335,7 +335,7 @@ static void *PosixTestThread( void *pData ) { (void)pData; TestThread(); - return NULL; + return nullptr; } #endif @@ -363,7 +363,7 @@ static int do_main(void) src_pj = custom_pj_init_plus_ctx( pj_get_default_ctx(), test->src_def ); dst_pj = custom_pj_init_plus_ctx( pj_get_default_ctx(), test->dst_def ); - if( src_pj == NULL ) + if( src_pj == nullptr ) { printf( "Unable to translate:\n%s\n", test->src_def ); test->skip = 1; @@ -371,7 +371,7 @@ static int do_main(void) continue; } - if( dst_pj == NULL ) + if( dst_pj == nullptr ) { printf( "Unable to translate:\n%s\n", test->dst_def ); test->skip = 1; @@ -439,7 +439,7 @@ static int do_main(void) active_thread_count++; pthread_create( &(ahThread[i]), &hThreadAttr, - PosixTestThread, NULL ); + PosixTestThread, nullptr ); } printf( "%d test threads launched.\n", num_threads ); diff --git a/src/nad2bin.cpp b/src/nad2bin.cpp index eb8672a5..ff8f2ebd 100644 --- a/src/nad2bin.cpp +++ b/src/nad2bin.cpp @@ -61,7 +61,7 @@ int main(int argc, char **argv) { long lam, laml, phi, phil; FILE *fp; - const char *output_file = NULL; + const char *output_file = nullptr; const char *format = "ctable2"; const char *GS_TYPE = "SECONDS"; @@ -81,7 +81,7 @@ int main(int argc, char **argv) { { format = argv[++i]; } - else if( output_file == NULL ) + else if( output_file == nullptr ) { output_file = argv[i]; } @@ -89,7 +89,7 @@ int main(int argc, char **argv) { Usage(); } - if( output_file == NULL ) + if( output_file == nullptr ) Usage(); fprintf( stdout, "Output Binary File Format: %s\n", format ); @@ -99,7 +99,7 @@ int main(int argc, char **argv) { /* ==================================================================== */ memset(ct.id,0,MAX_TAB_ID); - if ( NULL == fgets(ct.id, MAX_TAB_ID, stdin) ) { + if ( nullptr == fgets(ct.id, MAX_TAB_ID, stdin) ) { perror("fgets"); exit(1); } diff --git a/src/nad_init.cpp b/src/nad_init.cpp index 8b024ac7..1e2b150d 100644 --- a/src/nad_init.cpp +++ b/src/nad_init.cpp @@ -83,11 +83,11 @@ int nad_ctable_load( projCtx ctx, struct CTABLE *ct, PAFile fid ) /* read all the actual shift values */ a_size = ct->lim.lam * ct->lim.phi; ct->cvs = (FLP *) pj_malloc(sizeof(FLP) * a_size); - if( ct->cvs == NULL + if( ct->cvs == nullptr || pj_ctx_fread(ctx, ct->cvs, sizeof(FLP), a_size, fid) != a_size ) { pj_dalloc( ct->cvs ); - ct->cvs = NULL; + ct->cvs = nullptr; pj_log( ctx, PJ_LOG_ERROR, "ctable loading failed on fread() - binary incompatible?" ); @@ -111,12 +111,12 @@ struct CTABLE *nad_ctable_init( projCtx ctx, PAFile fid ) /* read the table header */ ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE)); - if( ct == NULL + if( ct == nullptr || pj_ctx_fread( ctx, ct, sizeof(struct CTABLE), 1, fid ) != 1 ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_dalloc( ct ); - return NULL; + return nullptr; } /* do some minimal validation to ensure the structure isn't corrupt */ @@ -125,7 +125,7 @@ struct CTABLE *nad_ctable_init( projCtx ctx, PAFile fid ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_dalloc( ct ); - return NULL; + return nullptr; } /* trim white space and newlines off id */ @@ -137,7 +137,7 @@ struct CTABLE *nad_ctable_init( projCtx ctx, PAFile fid ) break; } - ct->cvs = NULL; + ct->cvs = nullptr; return ct; } @@ -158,13 +158,13 @@ int nad_ctable2_load( projCtx ctx, struct CTABLE *ct, PAFile fid ) /* read all the actual shift values */ a_size = ct->lim.lam * ct->lim.phi; ct->cvs = (FLP *) pj_malloc(sizeof(FLP) * a_size); - if( ct->cvs == NULL + if( ct->cvs == nullptr || pj_ctx_fread(ctx, ct->cvs, sizeof(FLP), a_size, fid) != a_size ) { pj_dalloc( ct->cvs ); - ct->cvs = NULL; + ct->cvs = nullptr; - if( getenv("PROJ_DEBUG") != NULL ) + if( getenv("PROJ_DEBUG") != nullptr ) { fprintf( stderr, "ctable2 loading failed on fread() - binary incompatible?\n" ); @@ -197,7 +197,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); - return NULL; + return nullptr; } if( !IS_LSB ) @@ -210,15 +210,15 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) { pj_log( ctx, PJ_LOG_ERROR, "ctable2 - wrong header!" ); pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); - return NULL; + return nullptr; } /* read the table header */ ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE)); - if( ct == NULL ) + if( ct == nullptr ) { pj_ctx_set_errno( ctx, ENOMEM ); - return NULL; + return nullptr; } memcpy( ct->id, header + 16, 80 ); @@ -235,7 +235,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_dalloc( ct ); - return NULL; + return nullptr; } /* trim white space and newlines off id */ @@ -247,7 +247,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) break; } - ct->cvs = NULL; + ct->cvs = nullptr; return ct; } @@ -271,16 +271,16 @@ struct CTABLE *nad_init(projCtx ctx, char *name) /* -------------------------------------------------------------------- */ strcpy(fname, name); if (!(fid = pj_open_lib(ctx, fname, "rb"))) { - return 0; + return nullptr; } ct = nad_ctable_init( ctx, fid ); - if( ct != NULL ) + if( ct != nullptr ) { if( !nad_ctable_load( ctx, ct, fid ) ) { nad_free( ct ); - ct = NULL; + ct = nullptr; } } @@ -297,7 +297,7 @@ struct CTABLE *nad_init(projCtx ctx, char *name) void nad_free(struct CTABLE *ct) { if (ct) { - if( ct->cvs != NULL ) + if( ct->cvs != nullptr ) pj_dalloc(ct->cvs); pj_dalloc(ct); diff --git a/src/optargpm.h b/src/optargpm.h index 48cb260b..edd9fbee 100644 --- a/src/optargpm.h +++ b/src/optargpm.h @@ -107,8 +107,8 @@ int main(int argc, char **argv) { char *longkeys[] = {"o=output", "hello", 0}; o = opt_parse (argc, argv, "hv", "o", longflags, longkeys); - if (0==o) - return 0; + if (nullptr==o) + return nullptr; if (opt_given (o, "h")) { @@ -135,14 +135,14 @@ int main(int argc, char **argv) { char buf[1000]; int ret = fgets (buf, 1000, o->input); opt_eof_handler (o); - if (0==ret) { + if (nullptr==ret) { fprintf (stderr, "Read error in record %d\n", (int) o->record_index); continue; } do_what_needs_to_be_done (buf); } - return 0; + return nullptr; } @@ -229,22 +229,22 @@ struct OPTARGS { /* name of file currently read from */ char *opt_filename (OPTARGS *opt) { - if (0==opt) - return 0; + if (nullptr==opt) + return nullptr; if (0==opt->fargc) return opt->flaglevel; return opt->fargv[opt->input_index]; } static int opt_eof (OPTARGS *opt) { - if (0==opt) + if (nullptr==opt) return 1; return feof (opt->input); } /* record number of most recently read record */ int opt_record (OPTARGS *opt) { - if (0==opt) + if (nullptr==opt) return 0; return opt->record_index + 1; } @@ -252,11 +252,11 @@ int opt_record (OPTARGS *opt) { /* handle closing/opening of a "stream-of-streams" */ int opt_input_loop (OPTARGS *opt, int binary) { - if (0==opt) + if (nullptr==opt) return 0; /* most common case: increment record index and read on */ - if ( (opt->input!=0) && !feof (opt->input) ) { + if ( (opt->input!=nullptr) && !feof (opt->input) ) { opt->record_index++; return 1; } @@ -264,7 +264,7 @@ int opt_input_loop (OPTARGS *opt, int binary) { opt->record_index = 0; /* no input files specified - read from stdin */ - if ((0==opt->fargc) && (0==opt->input)) { + if ((0==opt->fargc) && (nullptr==opt->input)) { opt->input = stdin; return 1; } @@ -275,18 +275,18 @@ int opt_input_loop (OPTARGS *opt, int binary) { return 0; /* end if no more input */ - if (0!=opt->input) + if (nullptr!=opt->input) fclose (opt->input); if (opt->input_index >= opt->fargc) return 0; /* otherwise, open next input file */ opt->input = fopen (opt->fargv[opt->input_index++], binary? "rb": "rt"); - if (0 != opt->input) + if (nullptr != opt->input) return 1; /* ignore non-existing files - go on! */ - if (0==opt->input) + if (nullptr==opt->input) return opt_input_loop (opt, binary); return 0; } @@ -317,16 +317,16 @@ static int opt_raise_flag (OPTARGS *opt, int ordinal) { /* Find the ordinal value of any (short or long) option */ static int opt_ordinal (OPTARGS *opt, char *option) { int i; - if (0==opt) + if (nullptr==opt) return 0; - if (0==option) + if (nullptr==option) return 0; if (0==option[0]) return 0; /* An ordinary -o style short option */ if (strlen (option)==1) { /* Undefined option? */ - if (0==opt->optarg[(int) option[0]]) + if (nullptr==opt->optarg[(int) option[0]]) return 0; return (int) option[0]; } @@ -334,9 +334,9 @@ static int opt_ordinal (OPTARGS *opt, char *option) { /* --longname style long options are slightly harder */ for (i = 0; i < 64; i++) { const char **f = opt->longflags; - if (0==f) + if (nullptr==f) break; - if (0==f[i]) + if (nullptr==f[i]) break; if (0==strcmp(f[i], "END")) break; @@ -346,7 +346,7 @@ static int opt_ordinal (OPTARGS *opt, char *option) { /* long alias? - return ordinal for corresponding short */ if ((strlen(f[i]) > 2) && (f[i][1]=='=') && (0==strcmp(f[i]+2, option))) { /* Undefined option? */ - if (0==opt->optarg[(int) f[i][0]]) + if (nullptr==opt->optarg[(int) f[i][0]]) return 0; return (int) f[i][0]; } @@ -354,9 +354,9 @@ static int opt_ordinal (OPTARGS *opt, char *option) { for (i = 0; i < 64; i++) { const char **v = opt->longkeys; - if (0==v) + if (nullptr==v) return 0; - if (0==v[i]) + if (nullptr==v[i]) return 0; if (0==strcmp (v[i], "END")) return 0; @@ -366,14 +366,14 @@ static int opt_ordinal (OPTARGS *opt, char *option) { /* long alias? - return ordinal for corresponding short */ if ((strlen(v[i]) > 2) && (v[i][1]=='=') && (0==strcmp(v[i]+2, option))) { /* Undefined option? */ - if (0==opt->optarg[(int) v[i][0]]) + if (nullptr==opt->optarg[(int) v[i][0]]) return 0; return (int) v[i][0]; } } /* kill some potential compiler warnings about unused functions */ - (void) opt_eof (0); + (void) opt_eof (nullptr); return 0; } @@ -394,7 +394,7 @@ int opt_given (OPTARGS *opt, char *option) { char *opt_arg (OPTARGS *opt, char *option) { int ordinal = opt_ordinal (opt, option); if (0==ordinal) - return 0; + return nullptr; return opt->optarg[ordinal]; } @@ -418,8 +418,8 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, OPTARGS *o; o = (OPTARGS *) calloc (1, sizeof(OPTARGS)); - if (0==o) - return 0; + if (nullptr==o) + return nullptr; o->argc = argc; o->argv = argv; @@ -448,10 +448,10 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, continue; if ('='!=longflags[i][1]) continue; - if (0==strchr (flags, longflags[i][0])) { + if (nullptr==strchr (flags, longflags[i][0])) { fprintf (stderr, "%s: Invalid alias - '%s'. Valid short flags are '%s'\n", o->progname, longflags[i], flags); free (o); - return 0; + return nullptr; } } for (i = 0; longkeys && longkeys[i]; i++) { @@ -460,10 +460,10 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, continue; if ('='!=longkeys[i][1]) continue; - if (0==strchr (keys, longkeys[i][0])) { + if (nullptr==strchr (keys, longkeys[i][0])) { fprintf (stderr, "%s: Invalid alias - '%s'. Valid short flags are '%s'\n", o->progname, longkeys[i], keys); free (o); - return 0; + return nullptr; } } @@ -471,20 +471,20 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, /* flaglevel array to provide a pseudo-filename for the case of reading from stdin */ strcpy (o->flaglevel, "<stdin>"); - for (i = 128; (longflags != 0) && (longflags[i - 128] != 0); i++) { + for (i = 128; (longflags != nullptr) && (longflags[i - 128] != nullptr); i++) { if (i==192) { free (o); fprintf (stderr, "Too many flag style long options\n"); - return 0; + return nullptr; } o->optarg[i] = o->flaglevel; } - for (i = 192; (longkeys != 0) && (longkeys[i - 192] != 0); i++) { + for (i = 192; (longkeys != nullptr) && (longkeys[i - 192] != nullptr); i++) { if (i==256) { free (o); fprintf (stderr, "Too many value style long options\n"); - return 0; + return nullptr; } o->optarg[i] = argv[0]; } @@ -500,7 +500,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, if ('-' != argv[i][0]) break; - if (0==o->margv) + if (nullptr==o->margv) o->margv = argv + i; o->margc++; @@ -526,7 +526,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, c = opt_ordinal (o, crepr); if (0==c) { fprintf (stderr, "Invalid option \"%s\"\n", crepr); - return (OPTARGS *) 0; + return nullptr; } /* inline (gnu) --foo=bar style arg */ @@ -534,7 +534,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, *equals = '='; if (opt_is_flag (o, c)) { fprintf (stderr, "Option \"%s\" takes no arguments\n", crepr); - return (OPTARGS *) 0; + return nullptr; } o->optarg[c] = equals + 1; break; @@ -544,7 +544,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, if (!opt_is_flag (o, c)) { if ((argc==i + 1) || ('+'==argv[i+1][0]) || ('-'==argv[i+1][0])) { fprintf (stderr, "Missing argument for option \"%s\"\n", crepr); - return (OPTARGS *) 0; + return nullptr; } o->optarg[c] = argv[i + 1]; i++; /* eat the arg */ @@ -553,7 +553,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, if (!opt_is_flag (o, c)) { fprintf (stderr, "Expected flag style long option here, but got \"%s\"\n", crepr); - return (OPTARGS *) 0; + return nullptr; } /* Flag style option, i.e. taking no arguments */ @@ -562,9 +562,9 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, } /* classic short options */ - if (0==o->optarg[c]) { + if (nullptr==o->optarg[c]) { fprintf (stderr, "Invalid option \"%s\"\n", crepr); - return (OPTARGS *) 0; + return nullptr; } /* Flag style option, i.e. taking no arguments */ @@ -580,7 +580,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, if ((argc==i + 1) || ('+'==argv[i+1][0]) || ('-'==argv[i+1][0])) { fprintf (stderr, "Bad or missing arg for option \"%s\"\n", crepr); - return (OPTARGS *) 0; + return nullptr; } o->optarg[(int) c] = argv[i + 1]; i++; @@ -617,7 +617,7 @@ OPTARGS *opt_parse (int argc, char **argv, const char *flags, const char *keys, if ('-' == argv[i][0]) { free (o); fprintf (stderr, "+ and - style options must not be mixed\n"); - return 0; + return nullptr; } if ('+' != argv[i][0]) diff --git a/src/pj_apply_gridshift.cpp b/src/pj_apply_gridshift.cpp index 45ce5c8e..4c8115cc 100644 --- a/src/pj_apply_gridshift.cpp +++ b/src/pj_apply_gridshift.cpp @@ -57,7 +57,7 @@ int pj_apply_gridshift( projCtx ctx, const char *nadgrids, int inverse, gridlist = pj_gridlist_from_nadgrids( ctx, nadgrids, &grid_count ); - if( gridlist == NULL || grid_count == 0 ) + if( gridlist == nullptr || grid_count == 0 ) return ctx->last_errno; ret = pj_apply_gridshift_3( ctx, gridlist, grid_count, inverse, @@ -86,18 +86,18 @@ int pj_apply_gridshift_2( PJ *defn, int inverse, double *x, double *y, double *z ) { - if( defn->catalog_name != NULL ) + if( defn->catalog_name != nullptr ) return pj_gc_apply_gridshift( defn, inverse, point_count, point_offset, x, y, z ); - if( defn->gridlist == NULL ) + if( defn->gridlist == nullptr ) { defn->gridlist = pj_gridlist_from_nadgrids( pj_get_ctx( defn ), pj_param(defn->ctx, defn->params,"snadgrids").s, &(defn->gridlist_count) ); - if( defn->gridlist == NULL || defn->gridlist_count == 0 ) + if( defn->gridlist == nullptr || defn->gridlist_count == 0 ) return defn->ctx->last_errno; } @@ -135,7 +135,7 @@ static struct CTABLE* find_ctable(projCtx ctx, LP input, int grid_count, PJ_GRID { PJ_GRIDINFO *child; - for( child = gi->child; child != NULL; child = child->next ) + for( child = gi->child; child != nullptr; child = child->next ) { struct CTABLE *ct1 = child->ct; epsilon = (fabs(ct1->del.phi)+fabs(ct1->del.lam))/10000.0; @@ -150,24 +150,24 @@ static struct CTABLE* find_ctable(projCtx ctx, LP input, int grid_count, PJ_GRID } /* If we didn't find a child then nothing more to do */ - if( child == NULL ) break; + if( child == nullptr ) break; /* Otherwise use the child, first checking it's children */ gi = child; ct = child->ct; } /* load the grid shift info if we don't have it. */ - if( ct->cvs == NULL) { + if( ct->cvs == nullptr) { if (!pj_gridinfo_load( ctx, gi ) ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); - return NULL; + return nullptr; } } /* if we get this far we have found a suitable grid */ return ct; } - return NULL; + return nullptr; } /************************************************************************/ @@ -185,7 +185,7 @@ int pj_apply_gridshift_3( projCtx ctx, PJ_GRIDINFO **gridlist, int gridlist_coun static int debug_count = 0; (void) z; - if( gridlist== NULL || gridlist_count == 0 ) + if( gridlist== nullptr || gridlist_count == 0 ) { pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID); return PJD_ERR_FAILED_TO_LOAD_GRID; @@ -205,7 +205,7 @@ int pj_apply_gridshift_3( projCtx ctx, PJ_GRIDINFO **gridlist, int gridlist_coun output.lam = HUGE_VAL; ct = find_ctable(ctx, input, gridlist_count, gridlist); - if( ct != NULL ) + if( ct != nullptr ) { output = nad_cvt( input, inverse, ct ); @@ -280,14 +280,14 @@ int proj_hgrid_init(PJ* P, const char *grids) { char *sgrids = (char *) pj_malloc( (strlen(grids)+1+1) *sizeof(char) ); sprintf(sgrids, "%s%s", "s", grids); - if (P->gridlist == NULL) { + if (P->gridlist == nullptr) { P->gridlist = pj_gridlist_from_nadgrids( P->ctx, pj_param(P->ctx, P->params, sgrids).s, &(P->gridlist_count) ); - if( P->gridlist == NULL || P->gridlist_count == 0 ) { + if( P->gridlist == nullptr || P->gridlist_count == 0 ) { pj_dealloc(sgrids); return 0; } @@ -311,7 +311,7 @@ LP proj_hgrid_value(PJ *P, LP lp) { LP out = proj_coord_error().lp; ct = find_ctable(P->ctx, lp, P->gridlist_count, P->gridlist); - if (ct == 0) { + if (ct == nullptr) { pj_ctx_set_errno( P->ctx, PJD_ERR_GRID_AREA); return out; } @@ -340,7 +340,7 @@ LP proj_hgrid_apply(PJ *P, LP lp, PJ_DIRECTION direction) { ct = find_ctable(P->ctx, lp, P->gridlist_count, P->gridlist); - if (ct == NULL || ct->cvs == NULL) { + if (ct == nullptr || ct->cvs == nullptr) { pj_ctx_set_errno( P->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return out; } diff --git a/src/pj_apply_vgridshift.cpp b/src/pj_apply_vgridshift.cpp index c1344951..1facfed6 100644 --- a/src/pj_apply_vgridshift.cpp +++ b/src/pj_apply_vgridshift.cpp @@ -70,11 +70,11 @@ static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GR continue; /* If we have child nodes, check to see if any of them apply. */ - while( gi->child != NULL ) + while( gi->child != nullptr ) { PJ_GRIDINFO *child; - for( child = gi->child; child != NULL; child = child->next ) + for( child = gi->child; child != nullptr; child = child->next ) { struct CTABLE *ct1 = child->ct; @@ -87,7 +87,7 @@ static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GR } /* we didn't find a more refined child node to use, so go with current grid */ - if( child == NULL ) + if( child == nullptr ) { break; } @@ -98,7 +98,7 @@ static double read_vgrid_value( PJ *defn, LP input, int *gridlist_count_p, PJ_GR } /* load the grid shift info if we don't have it. */ - if( ct->cvs == NULL && !pj_gridinfo_load( pj_get_ctx(defn), gi ) ) + if( ct->cvs == nullptr && !pj_gridinfo_load( pj_get_ctx(defn), gi ) ) { pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return PJD_ERR_FAILED_TO_LOAD_GRID; @@ -189,14 +189,14 @@ int pj_apply_vgridshift( PJ *defn, const char *listname, PJ_GRIDINFO **tables; struct CTABLE ct; - if( *gridlist_p == NULL ) + if( *gridlist_p == nullptr ) { *gridlist_p = pj_gridlist_from_nadgrids( pj_get_ctx(defn), pj_param(defn->ctx,defn->params,listname).s, gridlist_count_p ); - if( *gridlist_p == NULL || *gridlist_count_p == 0 ) + if( *gridlist_p == nullptr || *gridlist_count_p == 0 ) return defn->ctx->last_errno; } @@ -288,14 +288,14 @@ int proj_vgrid_init(PJ* P, const char *grids) { char *sgrids = (char *) pj_malloc( (strlen(grids)+1+1) *sizeof(char) ); sprintf(sgrids, "%s%s", "s", grids); - if (P->vgridlist_geoid == NULL) { + if (P->vgridlist_geoid == nullptr) { P->vgridlist_geoid = pj_gridlist_from_nadgrids( P->ctx, pj_param(P->ctx, P->params, sgrids).s, &(P->vgridlist_geoid_count) ); - if( P->vgridlist_geoid == NULL || P->vgridlist_geoid_count == 0 ) { + if( P->vgridlist_geoid == nullptr || P->vgridlist_geoid_count == 0 ) { pj_dealloc(sgrids); return 0; } diff --git a/src/pj_auth.cpp b/src/pj_auth.cpp index d6024671..cde60a29 100644 --- a/src/pj_auth.cpp +++ b/src/pj_auth.cpp @@ -17,7 +17,7 @@ pj_authset(double es) { double t, *APA; - if ((APA = (double *)pj_malloc(APA_SIZE * sizeof(double))) != NULL) { + if ((APA = (double *)pj_malloc(APA_SIZE * sizeof(double))) != nullptr) { APA[0] = es * P00; t = es * es; APA[0] += t * P01; diff --git a/src/pj_ctx.cpp b/src/pj_ctx.cpp index 1c99e921..ab51d6c1 100644 --- a/src/pj_ctx.cpp +++ b/src/pj_ctx.cpp @@ -42,9 +42,9 @@ static volatile int default_context_initialized = 0; projCtx pj_get_ctx( projPJ pj ) { - if (0==pj) + if (nullptr==pj) return pj_get_default_ctx (); - if (0==pj->ctx) + if (nullptr==pj->ctx) return pj_get_default_ctx (); return pj->ctx; } @@ -58,7 +58,7 @@ projCtx pj_get_ctx( projPJ pj ) void pj_set_ctx( projPJ pj, projCtx ctx ) { - if (pj==0) + if (pj==nullptr) return; pj->ctx = ctx; } @@ -82,13 +82,13 @@ projCtx pj_get_default_ctx() default_context.last_errno = 0; default_context.debug_level = PJ_LOG_NONE; default_context.logger = pj_stderr_logger; - default_context.app_data = NULL; + default_context.app_data = nullptr; default_context.fileapi = pj_get_default_fileapi(); - default_context.cpp_context = NULL; + default_context.cpp_context = nullptr; default_context.use_proj4_init_rules = -1; default_context.epsg_file_exists = -1; - if( getenv("PROJ_DEBUG") != NULL ) + if( getenv("PROJ_DEBUG") != nullptr ) { if( atoi(getenv("PROJ_DEBUG")) >= -PJ_LOG_DEBUG_MINOR ) default_context.debug_level = atoi(getenv("PROJ_DEBUG")); @@ -111,11 +111,11 @@ projCtx pj_ctx_alloc() { projCtx ctx = (projCtx_t *) malloc(sizeof(projCtx_t)); - if (0==ctx) - return 0; + if (nullptr==ctx) + return nullptr; memcpy( ctx, pj_get_default_ctx(), sizeof(projCtx_t) ); ctx->last_errno = 0; - ctx->cpp_context = NULL; + ctx->cpp_context = nullptr; ctx->use_proj4_init_rules = -1; return ctx; @@ -139,7 +139,7 @@ void pj_ctx_free( projCtx ctx ) int pj_ctx_get_errno( projCtx ctx ) { - if (0==ctx) + if (nullptr==ctx) return pj_get_default_ctx ()->last_errno; return ctx->last_errno; } @@ -167,7 +167,7 @@ void pj_ctx_set_errno( projCtx ctx, int new_errno ) void pj_ctx_set_debug( projCtx ctx, int new_debug ) { - if (0==ctx) + if (nullptr==ctx) return; ctx->debug_level = new_debug; } @@ -179,7 +179,7 @@ void pj_ctx_set_debug( projCtx ctx, int new_debug ) void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) ) { - if (0==ctx) + if (nullptr==ctx) return; ctx->logger = new_logger; } @@ -191,7 +191,7 @@ void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) ) void pj_ctx_set_app_data( projCtx ctx, void *new_app_data ) { - if (0==ctx) + if (nullptr==ctx) return; ctx->app_data = new_app_data; } @@ -203,8 +203,8 @@ void pj_ctx_set_app_data( projCtx ctx, void *new_app_data ) void *pj_ctx_get_app_data( projCtx ctx ) { - if (0==ctx) - return 0; + if (nullptr==ctx) + return nullptr; return ctx->app_data; } @@ -215,7 +215,7 @@ void *pj_ctx_get_app_data( projCtx ctx ) void pj_ctx_set_fileapi( projCtx ctx, projFileAPI *fileapi ) { - if (0==ctx) + if (nullptr==ctx) return; ctx->fileapi = fileapi; } @@ -227,7 +227,7 @@ void pj_ctx_set_fileapi( projCtx ctx, projFileAPI *fileapi ) projFileAPI *pj_ctx_get_fileapi( projCtx ctx ) { - if (0==ctx) - return 0; + if (nullptr==ctx) + return nullptr; return ctx->fileapi; } diff --git a/src/pj_datum_set.cpp b/src/pj_datum_set.cpp index 466b56c5..c9dfdb80 100644 --- a/src/pj_datum_set.cpp +++ b/src/pj_datum_set.cpp @@ -54,7 +54,7 @@ int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef) /* definition will last into the pj_ell_set() function called */ /* after this one. */ /* -------------------------------------------------------------------- */ - if( (name = pj_param(ctx, pl,"sdatum").s) != NULL ) + if( (name = pj_param(ctx, pl,"sdatum").s) != nullptr ) { paralist *curr; const char *s; @@ -96,7 +96,7 @@ int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef) /* Check for nadgrids parameter. */ /* -------------------------------------------------------------------- */ nadgrids = pj_param(ctx, pl,"snadgrids").s; - if( nadgrids != NULL ) + if( nadgrids != nullptr ) { /* We don't actually save the value separately. It will continue to exist int he param list for use in pj_apply_gridshift.c */ @@ -107,7 +107,7 @@ int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef) /* -------------------------------------------------------------------- */ /* Check for grid catalog parameter, and optional date. */ /* -------------------------------------------------------------------- */ - else if( (catalog = pj_param(ctx, pl,"scatalog").s) != NULL ) + else if( (catalog = pj_param(ctx, pl,"scatalog").s) != nullptr ) { const char *date; @@ -119,14 +119,14 @@ int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef) } date = pj_param(ctx, pl, "sdate").s; - if( date != NULL) + if( date != nullptr) projdef->datum_date = pj_gc_parsedate( ctx, date); } /* -------------------------------------------------------------------- */ /* Check for towgs84 parameter. */ /* -------------------------------------------------------------------- */ - else if( (towgs84 = pj_param(ctx, pl,"stowgs84").s) != NULL ) + else if( (towgs84 = pj_param(ctx, pl,"stowgs84").s) != nullptr ) { int parm_count = 0; const char *s; diff --git a/src/pj_datums.cpp b/src/pj_datums.cpp index 2951b7bd..acbe12f7 100644 --- a/src/pj_datums.cpp +++ b/src/pj_datums.cpp @@ -65,7 +65,7 @@ C_NAMESPACE_VAR const struct PJ_DATUMS pj_datums[] = { "intl", "New Zealand Geodetic Datum 1949"}, {"OSGB36", "towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894", "airy", "Airy 1830"}, -{NULL, NULL, NULL, NULL} +{nullptr, nullptr, nullptr, nullptr} }; struct PJ_DATUMS *pj_get_datums_ref() @@ -90,7 +90,7 @@ static const struct PJ_PRIME_MERIDIANS pj_prime_meridians[] = { {"athens", "23d42'58.815\"E"}, {"oslo", "10d43'22.5\"E"}, {"copenhagen","12d34'40.35\"E"}, - {NULL, NULL} + {nullptr, nullptr} }; const PJ_PRIME_MERIDIANS *proj_list_prime_meridians(void) diff --git a/src/pj_deriv.cpp b/src/pj_deriv.cpp index 2c91e0cc..0e285265 100644 --- a/src/pj_deriv.cpp +++ b/src/pj_deriv.cpp @@ -9,7 +9,7 @@ int pj_deriv(LP lp, double h, const PJ *P, struct DERIVS *der) { XY t; /* get rid of constness until we can do it for real */ PJ *Q = (PJ *) P; - if (0==Q->fwd) + if (nullptr==Q->fwd) return 1; lp.lam += h; diff --git a/src/pj_ell_set.cpp b/src/pj_ell_set.cpp index e2d2750c..9d7fae0a 100644 --- a/src/pj_ell_set.cpp +++ b/src/pj_ell_set.cpp @@ -77,7 +77,7 @@ int pj_ellipsoid (PJ *P) { int err = proj_errno_reset (P); char *empty = {""}; - P->def_size = P->def_shape = P->def_spherification = P->def_ellps = 0; + P->def_size = P->def_shape = P->def_spherification = P->def_ellps = nullptr; /* Specifying R overrules everything */ if (pj_get_param (P->params, "R")) { @@ -129,13 +129,13 @@ static int ellps_ellps (PJ *P) { /***************************************************************************************/ PJ B; const PJ_ELLPS *ellps; - paralist *par = 0; + paralist *par = nullptr; char *name; int err; /* Sail home if ellps=xxx is not specified */ par = pj_get_param (P->params, "ellps"); - if (0==par) + if (nullptr==par) return 0; /* Otherwise produce a fake PJ to make ellps_size/ellps_shape do the hard work for us */ @@ -148,7 +148,7 @@ static int ellps_ellps (PJ *P) { return proj_errno_set (P, PJD_ERR_INVALID_ARG); name = par->param + 6; ellps = pj_find_ellps (name); - if (0==ellps) + if (nullptr==ellps) return proj_errno_set (P, PJD_ERR_UNKNOWN_ELLP_PARAM); /* Now, get things ready for ellps_size/ellps_shape, make them do their thing, and clean up */ @@ -178,7 +178,7 @@ static int ellps_ellps (PJ *P) { /***************************************************************************************/ static int ellps_size (PJ *P) { /***************************************************************************************/ - paralist *par = 0; + paralist *par = nullptr; int a_was_set = 0; /* A size parameter *must* be given, but may have been given as ellps prior */ @@ -187,9 +187,9 @@ static int ellps_size (PJ *P) { /* Check which size key is specified */ par = pj_get_param (P->params, "R"); - if (0==par) + if (nullptr==par) par = pj_get_param (P->params, "a"); - if (0==par) + if (nullptr==par) return a_was_set? 0: proj_errno_set (P, PJD_ERR_MAJOR_AXIS_NOT_GIVEN); P->def_size = par->param; @@ -212,11 +212,11 @@ static int ellps_size (PJ *P) { static int ellps_shape (PJ *P) { /***************************************************************************************/ char *keys[] = {"rf", "f", "es", "e", "b"}; - paralist *par = 0; - char *def = 0; + paralist *par = nullptr; + char *def = nullptr; size_t i, len; - par = 0; + par = nullptr; len = sizeof (keys) / sizeof (char *); /* Check which shape key is specified */ @@ -228,9 +228,9 @@ static int ellps_shape (PJ *P) { /* Not giving a shape parameter means selecting a sphere, unless shape */ /* has been selected previously via ellps=xxx */ - if (0==par && P->es != 0) + if (nullptr==par && P->es != 0) return 0; - if (0==par && P->es==0) { + if (nullptr==par && P->es==0) { P->es = P->f = 0; P->b = P->a; return 0; @@ -319,14 +319,14 @@ static int ellps_spherification (PJ *P) { /***************************************************************************************/ char *keys[] = {"R_A", "R_V", "R_a", "R_g", "R_h", "R_lat_a", "R_lat_g"}; size_t len, i; - paralist *par = 0; - char *def = 0; + paralist *par = nullptr; + char *def = nullptr; double t; char *v, *endp; len = sizeof (keys) / sizeof (char *); - P->def_spherification = 0; + P->def_spherification = nullptr; /* Check which spherification key is specified */ for (i = 0; i < len; i++) { @@ -410,8 +410,8 @@ static paralist *pj_get_param (paralist *list, char *key) { static char *pj_param_value (paralist *list) { char *key, *value; - if (0==list) - return 0; + if (nullptr==list) + return nullptr; key = list->param; value = strchr (key, '='); @@ -426,15 +426,15 @@ static const PJ_ELLPS *pj_find_ellps (char *name) { const char *s; const PJ_ELLPS *ellps; - if (0==name) - return 0; + if (nullptr==name) + return nullptr; ellps = proj_list_ellps(); /* Search through internal ellipsoid list for name */ for (i = 0; (s = ellps[i].id) && strcmp(name, s) ; ++i); - if (0==s) - return 0; + if (nullptr==s) + return nullptr; return ellps + i; } diff --git a/src/pj_ellps.cpp b/src/pj_ellps.cpp index 8b3b8f0a..f548d30d 100644 --- a/src/pj_ellps.cpp +++ b/src/pj_ellps.cpp @@ -53,7 +53,7 @@ pj_ellps[] = { {"WGS72", "a=6378135.0", "rf=298.26", "WGS 72"}, {"WGS84", "a=6378137.0", "rf=298.257223563", "WGS 84"}, {"sphere", "a=6370997.0", "b=6370997.0", "Normal Sphere (r=6370997)"}, -{NULL, NULL, NULL, NULL} +{nullptr, nullptr, nullptr, nullptr} }; const PJ_ELLPS *proj_list_ellps(void) diff --git a/src/pj_factors.cpp b/src/pj_factors.cpp index e4b871a1..768bf585 100644 --- a/src/pj_factors.cpp +++ b/src/pj_factors.cpp @@ -21,10 +21,10 @@ int pj_factors(LP lp, const PJ *P, double h, struct FACTORS *fac) { /* Failing the 3 initial checks will most likely be due to */ /* earlier errors, so we leave errno alone */ - if (0==fac) + if (nullptr==fac) return 1; - if (0==P) + if (nullptr==P) return 1; if (HUGE_VAL==lp.lam) diff --git a/src/pj_fileapi.cpp b/src/pj_fileapi.cpp index eba96afd..3df73236 100644 --- a/src/pj_fileapi.cpp +++ b/src/pj_fileapi.cpp @@ -75,9 +75,9 @@ static PAFile stdio_fopen(projCtx ctx, const char *filename, FILE *fp; fp = fopen(filename, access); - if (fp == NULL) + if (fp == nullptr) { - return NULL; + return nullptr; } pafile = (stdio_pafile *) malloc(sizeof(stdio_pafile)); @@ -85,7 +85,7 @@ static PAFile stdio_fopen(projCtx ctx, const char *filename, { pj_ctx_set_errno(ctx, ENOMEM); fclose(fp); - return NULL; + return nullptr; } pafile->fp = fp; @@ -193,7 +193,7 @@ char *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file) line[size-1] = '\0'; bytes_read = pj_ctx_fread(ctx, line, 1, size-1, file); if(bytes_read == 0) - return NULL; + return nullptr; if(bytes_read < (size_t)size) { line[bytes_read] = '\0'; diff --git a/src/pj_fwd.cpp b/src/pj_fwd.cpp index 38443f07..e8f73999 100644 --- a/src/pj_fwd.cpp +++ b/src/pj_fwd.cpp @@ -74,7 +74,7 @@ static PJ_COORD fwd_prepare (PJ *P, PJ_COORD coo) { if (P->hgridshift) coo = proj_trans (P->hgridshift, PJ_INV, coo); - else if (P->helmert || (P->cart_wgs84 != 0 && P->cart != 0)) { + else if (P->helmert || (P->cart_wgs84 != nullptr && P->cart != nullptr)) { coo = proj_trans (P->cart_wgs84, PJ_FWD, coo); /* Go cartesian in WGS84 frame */ if( P->helmert ) coo = proj_trans (P->helmert, PJ_INV, coo); /* Step into local frame */ diff --git a/src/pj_gauss.cpp b/src/pj_gauss.cpp index 45b93f59..2db713ad 100644 --- a/src/pj_gauss.cpp +++ b/src/pj_gauss.cpp @@ -50,8 +50,8 @@ void *pj_gauss_ini(double e, double phi0, double *chi, double *rc) { double sphi, cphi, es; struct GAUSS *en; - if ((en = (struct GAUSS *)malloc(sizeof(struct GAUSS))) == NULL) - return (NULL); + if ((en = (struct GAUSS *)malloc(sizeof(struct GAUSS))) == nullptr) + return (nullptr); es = e * e; en->e = e; sphi = sin(phi0); @@ -60,7 +60,7 @@ void *pj_gauss_ini(double e, double phi0, double *chi, double *rc) { en->C = sqrt(1. + es * cphi * cphi / (1. - es)); if (en->C == 0.0) { free(en); - return NULL; + return nullptr; } *chi = asin(sphi / en->C); en->ratexp = 0.5 * en->C * e; diff --git a/src/pj_gc_reader.cpp b/src/pj_gc_reader.cpp index 493fc075..118aadf6 100644 --- a/src/pj_gc_reader.cpp +++ b/src/pj_gc_reader.cpp @@ -50,8 +50,8 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) char line[302]; fid = pj_open_lib( ctx, catalog_name, "r" ); - if (fid == NULL) - return NULL; + if (fid == nullptr) + return nullptr; /* discard title line */ pj_ctx_fgets(ctx, line, sizeof(line)-1, fid); @@ -61,7 +61,7 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) { pj_ctx_set_errno(ctx, ENOMEM); pj_ctx_fclose(ctx, fid); - return NULL; + return nullptr; } catalog->catalog_name = pj_strdup(catalog_name); @@ -69,7 +69,7 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) pj_ctx_set_errno(ctx, ENOMEM); free(catalog); pj_ctx_fclose(ctx, fid); - return NULL; + return nullptr; } entry_max = 10; @@ -80,7 +80,7 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) free(catalog->catalog_name); free(catalog); pj_ctx_fclose(ctx, fid); - return NULL; + return nullptr; } while( gc_readentry( ctx, fid, @@ -95,7 +95,7 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) new_entries = (PJ_GridCatalogEntry *) realloc(catalog->entries, entry_max * sizeof(PJ_GridCatalogEntry)); - if (new_entries == NULL ) + if (new_entries == nullptr ) { int i; for( i = 0; i < catalog->entry_count; i++ ) @@ -104,7 +104,7 @@ PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) free( catalog->catalog_name ); free( catalog ); pj_ctx_fclose(ctx, fid); - return NULL; + return nullptr; } catalog->entries = new_entries; } @@ -127,7 +127,7 @@ static int gc_read_csv_line( projCtx ctx, PAFile fid, { char line[302]; - while( pj_ctx_fgets(ctx, line, sizeof(line)-1, fid) != NULL ) + while( pj_ctx_fgets(ctx, line, sizeof(line)-1, fid) != nullptr ) { char *next = line; int token_count = 0; @@ -226,11 +226,11 @@ static int gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry) else { entry->definition = tokens[0]; - tokens[0] = NULL; /* We take ownership of tokens[0] */ - entry->region.ll_long = dmstor_ctx( ctx, tokens[1], NULL ); - entry->region.ll_lat = dmstor_ctx( ctx, tokens[2], NULL ); - entry->region.ur_long = dmstor_ctx( ctx, tokens[3], NULL ); - entry->region.ur_lat = dmstor_ctx( ctx, tokens[4], NULL ); + tokens[0] = nullptr; /* We take ownership of tokens[0] */ + entry->region.ll_long = dmstor_ctx( ctx, tokens[1], nullptr ); + entry->region.ll_lat = dmstor_ctx( ctx, tokens[2], nullptr ); + entry->region.ur_long = dmstor_ctx( ctx, tokens[3], nullptr ); + entry->region.ur_lat = dmstor_ctx( ctx, tokens[4], nullptr ); if( token_count > 5 ) entry->priority = atoi( tokens[5] ); /* defaults to zero */ if( token_count > 6 ) diff --git a/src/pj_gridcatalog.cpp b/src/pj_gridcatalog.cpp index ea9c4aa1..fef2df56 100644 --- a/src/pj_gridcatalog.cpp +++ b/src/pj_gridcatalog.cpp @@ -34,7 +34,7 @@ #include "projects.h" -static PJ_GridCatalog *grid_catalog_list = NULL; +static PJ_GridCatalog *grid_catalog_list = nullptr; /************************************************************************/ /* pj_gc_unloadall() */ @@ -47,7 +47,7 @@ void pj_gc_unloadall( projCtx ctx ) { (void) ctx; - while( grid_catalog_list != NULL ) + while( grid_catalog_list != nullptr ) { int i; PJ_GridCatalog *catalog = grid_catalog_list; @@ -75,7 +75,7 @@ PJ_GridCatalog *pj_gc_findcatalog( projCtx ctx, const char *name ) pj_acquire_lock(); - for( catalog=grid_catalog_list; catalog != NULL; catalog = catalog->next ) + for( catalog=grid_catalog_list; catalog != nullptr; catalog = catalog->next ) { if( strcmp(catalog->catalog_name, name) == 0 ) { @@ -87,8 +87,8 @@ PJ_GridCatalog *pj_gc_findcatalog( projCtx ctx, const char *name ) pj_release_lock(); catalog = pj_gc_readcatalog( ctx, name ); - if( catalog == NULL ) - return NULL; + if( catalog == nullptr ) + return nullptr; pj_acquire_lock(); catalog->next = grid_catalog_list; @@ -110,10 +110,10 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, int i; (void) z; - if( defn->catalog == NULL ) + if( defn->catalog == nullptr ) { defn->catalog = pj_gc_findcatalog( defn->ctx, defn->catalog_name ); - if( defn->catalog == NULL ) + if( defn->catalog == nullptr ) return defn->ctx->last_errno; } @@ -130,7 +130,7 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, input.lam = x[io]; /* make sure we have appropriate "after" shift file available */ - if( defn->last_after_grid == NULL + if( defn->last_after_grid == nullptr || input.lam < defn->last_after_region.ll_long || input.lam > defn->last_after_region.ur_long || input.phi < defn->last_after_region.ll_lat @@ -140,17 +140,17 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, 1, input, defn->datum_date, &(defn->last_after_region), &(defn->last_after_date)); - if( defn->last_after_grid == NULL ) + if( defn->last_after_grid == nullptr ) { pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return PJD_ERR_FAILED_TO_LOAD_GRID; } } gi = defn->last_after_grid; - assert( gi->child == NULL ); + assert( gi->child == nullptr ); /* load the grid shift info if we don't have it. */ - if( gi->ct->cvs == NULL && !pj_gridinfo_load( defn->ctx, gi ) ) + if( gi->ct->cvs == nullptr && !pj_gridinfo_load( defn->ctx, gi ) ) { pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return PJD_ERR_FAILED_TO_LOAD_GRID; @@ -178,7 +178,7 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, } /* make sure we have appropriate "before" shift file available */ - if( defn->last_before_grid == NULL + if( defn->last_before_grid == nullptr || input.lam < defn->last_before_region.ll_long || input.lam > defn->last_before_region.ur_long || input.phi < defn->last_before_region.ll_lat @@ -188,7 +188,7 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, 0, input, defn->datum_date, &(defn->last_before_region), &(defn->last_before_date)); - if( defn->last_before_grid == NULL ) + if( defn->last_before_grid == nullptr ) { pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return PJD_ERR_FAILED_TO_LOAD_GRID; @@ -196,10 +196,10 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, } gi = defn->last_before_grid; - assert( gi->child == NULL ); + assert( gi->child == nullptr ); /* load the grid shift info if we don't have it. */ - if( gi->ct->cvs == NULL && !pj_gridinfo_load( defn->ctx, gi ) ) + if( gi->ct->cvs == nullptr && !pj_gridinfo_load( defn->ctx, gi ) ) { pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return PJD_ERR_FAILED_TO_LOAD_GRID; @@ -241,7 +241,7 @@ PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx, PJ_GridCatalog *catalog, int after, double *grid_date ) { int iEntry; - PJ_GridCatalogEntry *entry = NULL; + PJ_GridCatalogEntry *entry = nullptr; for( iEntry = 0; iEntry < catalog->entry_count; iEntry++ ) { @@ -263,13 +263,13 @@ PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx, PJ_GridCatalog *catalog, int after, break; } - if( entry == NULL ) + if( entry == nullptr ) { if( grid_date ) *grid_date = 0.0; - if( optional_region != NULL ) + if( optional_region != nullptr ) memset( optional_region, 0, sizeof(PJ_Region)); - return NULL; + return nullptr; } if( grid_date ) @@ -280,9 +280,9 @@ PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx, PJ_GridCatalog *catalog, int after, } - if( entry->gridinfo == NULL ) + if( entry->gridinfo == nullptr ) { - PJ_GRIDINFO **gridlist = NULL; + PJ_GRIDINFO **gridlist = nullptr; int grid_count = 0; gridlist = pj_gridlist_from_nadgrids( ctx, entry->definition, &grid_count); diff --git a/src/pj_gridinfo.cpp b/src/pj_gridinfo.cpp index de0e8d31..046abfcc 100644 --- a/src/pj_gridinfo.cpp +++ b/src/pj_gridinfo.cpp @@ -89,25 +89,25 @@ static double to_double( unsigned char* data ) void pj_gridinfo_free( projCtx ctx, PJ_GRIDINFO *gi ) { - if( gi == NULL ) + if( gi == nullptr ) return; - if( gi->child != NULL ) + if( gi->child != nullptr ) { PJ_GRIDINFO *child, *next; - for( child = gi->child; child != NULL; child=next) + for( child = gi->child; child != nullptr; child=next) { next=child->next; pj_gridinfo_free( ctx, child ); } } - if( gi->ct != NULL ) + if( gi->ct != nullptr ) nad_free( gi->ct ); free( gi->gridname ); - if( gi->filename != NULL ) + if( gi->filename != nullptr ) free( gi->filename ); pj_dalloc( gi ); @@ -126,11 +126,11 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) { struct CTABLE ct_tmp; - if( gi == NULL || gi->ct == NULL ) + if( gi == nullptr || gi->ct == nullptr ) return 0; pj_acquire_lock(); - if( gi->ct->cvs != NULL ) + if( gi->ct->cvs != nullptr ) { pj_release_lock(); return 1; @@ -148,7 +148,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) fid = pj_open_lib( ctx, gi->filename, "rb" ); - if( fid == NULL ) + if( fid == nullptr ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); @@ -175,7 +175,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) fid = pj_open_lib( ctx, gi->filename, "rb" ); - if( fid == NULL ) + if( fid == nullptr ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); @@ -207,7 +207,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) fid = pj_open_lib( ctx, gi->filename, "rb" ); - if( fid == NULL ) + if( fid == nullptr ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); @@ -218,7 +218,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) row_buf = (double *) pj_malloc(gi->ct->lim.lam * sizeof(double) * 2); ct_tmp.cvs = (FLP *) pj_malloc(gi->ct->lim.lam*gi->ct->lim.phi*sizeof(FLP)); - if( row_buf == NULL || ct_tmp.cvs == NULL ) + if( row_buf == nullptr || ct_tmp.cvs == nullptr ) { pj_dalloc( row_buf ); pj_dalloc( ct_tmp.cvs ); @@ -288,7 +288,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) fid = pj_open_lib( ctx, gi->filename, "rb" ); - if( fid == NULL ) + if( fid == nullptr ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); @@ -299,7 +299,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) row_buf = (float *) pj_malloc(gi->ct->lim.lam * sizeof(float) * 4); ct_tmp.cvs = (FLP *) pj_malloc(gi->ct->lim.lam*gi->ct->lim.phi*sizeof(FLP)); - if( row_buf == NULL || ct_tmp.cvs == NULL ) + if( row_buf == nullptr || ct_tmp.cvs == nullptr ) { pj_dalloc( row_buf ); pj_dalloc( ct_tmp.cvs ); @@ -363,7 +363,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) fid = pj_open_lib( ctx, gi->filename, "rb" ); - if( fid == NULL ) + if( fid == nullptr ) { pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); @@ -373,7 +373,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) pj_ctx_fseek( ctx, fid, gi->grid_offset, SEEK_SET ); ct_tmp.cvs = (FLP *) pj_malloc(words*sizeof(float)); - if( ct_tmp.cvs == NULL ) + if( ct_tmp.cvs == nullptr ) { pj_ctx_set_errno( ctx, ENOMEM ); pj_release_lock(); @@ -563,7 +563,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) return 0; } - ct->cvs = NULL; + ct->cvs = nullptr; /* -------------------------------------------------------------------- */ /* Create a new gridinfo for this if we aren't processing the */ @@ -590,7 +590,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) pj_ctx_set_errno(ctx, ENOMEM); return 0; } - gi->next = NULL; + gi->next = nullptr; } gi->must_swap = must_swap; @@ -607,7 +607,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) { PJ_GRIDINFO *lnk; - for( lnk = gilist; lnk->next != NULL; lnk = lnk->next ) {} + for( lnk = gilist; lnk->next != nullptr; lnk = lnk->next ) {} lnk->next = gi; } } @@ -618,25 +618,25 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) PJ_GRIDINFO *gp = gridinfo_parent(gilist, (const char*)header+24,8); - if( gp == NULL ) + if( gp == nullptr ) { pj_log( ctx, PJ_LOG_ERROR, "pj_gridinfo_init_ntv2(): " "failed to find parent %8.8s for %s.", (const char *) header+24, gi->ct->id ); - for( lnk = gilist; lnk->next != NULL; lnk = lnk->next ) {} + for( lnk = gilist; lnk->next != nullptr; lnk = lnk->next ) {} lnk->next = gi; } else { - if( gp->child == NULL ) + if( gp->child == nullptr ) { gp->child = gi; } else { - for( lnk = gp->child; lnk->next != NULL; lnk = lnk->next ) {} + for( lnk = gp->child; lnk->next != nullptr; lnk = lnk->next ) {} lnk->next = gi; } } @@ -728,7 +728,7 @@ static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) ct->ll.phi *= DEG_TO_RAD; ct->del.lam *= DEG_TO_RAD; ct->del.phi *= DEG_TO_RAD; - ct->cvs = NULL; + ct->cvs = nullptr; gi->ct = ct; gi->grid_offset = (long) sizeof(header); @@ -830,7 +830,7 @@ static int pj_gridinfo_init_gtx( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) ct->ll.phi *= DEG_TO_RAD; ct->del.lam *= DEG_TO_RAD; ct->del.phi *= DEG_TO_RAD; - ct->cvs = NULL; + ct->cvs = nullptr; gi->ct = ct; gi->grid_offset = 40; @@ -867,20 +867,20 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname ) gilist = (PJ_GRIDINFO *) pj_calloc(1, sizeof(PJ_GRIDINFO)); if (!gilist) { pj_ctx_set_errno(ctx, ENOMEM); - return NULL; + return nullptr; } gilist->gridname = pj_strdup( gridname ); if (!gilist->gridname) { pj_dalloc(gilist); pj_ctx_set_errno(ctx, ENOMEM); - return NULL; + return nullptr; } - gilist->filename = NULL; + gilist->filename = nullptr; gilist->format = "missing"; gilist->grid_offset = 0; - gilist->ct = NULL; - gilist->next = NULL; + gilist->ct = nullptr; + gilist->next = nullptr; /* -------------------------------------------------------------------- */ /* Open the file using the usual search rules. */ @@ -896,7 +896,7 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname ) pj_dalloc(gilist->gridname); pj_dalloc(gilist); pj_ctx_set_errno(ctx, ENOMEM); - return NULL; + return nullptr; } /* -------------------------------------------------------------------- */ @@ -946,7 +946,7 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname ) gilist->format = "ctable2"; gilist->ct = ct; - if (ct == NULL) + if (ct == nullptr) { pj_log( ctx, PJ_LOG_DEBUG_MAJOR, "CTABLE V2 ct is NULL."); @@ -966,7 +966,7 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname ) else { struct CTABLE *ct = nad_ctable_init( ctx, fp ); - if (ct == NULL) + if (ct == nullptr) { pj_log( ctx, PJ_LOG_DEBUG_MAJOR, "CTABLE ct is NULL."); diff --git a/src/pj_gridlist.cpp b/src/pj_gridlist.cpp index 332de8dd..169abcb9 100644 --- a/src/pj_gridlist.cpp +++ b/src/pj_gridlist.cpp @@ -34,7 +34,7 @@ #include "projects.h" -static PJ_GRIDINFO *grid_list = NULL; +static PJ_GRIDINFO *grid_list = nullptr; #define PJ_MAX_PATH_LENGTH 1024 /************************************************************************/ @@ -46,11 +46,11 @@ static PJ_GRIDINFO *grid_list = NULL; void pj_deallocate_grids() { - while( grid_list != NULL ) + while( grid_list != nullptr ) { PJ_GRIDINFO *item = grid_list; grid_list = grid_list->next; - item->next = NULL; + item->next = nullptr; pj_gridinfo_free( pj_get_default_ctx(), item ); } @@ -71,21 +71,21 @@ static int pj_gridlist_merge_gridfile( projCtx ctx, { int got_match=0; - PJ_GRIDINFO *this_grid, *tail = NULL; + PJ_GRIDINFO *this_grid, *tail = nullptr; /* -------------------------------------------------------------------- */ /* Try to find in the existing list of loaded grids. Add all */ /* matching grids as with NTv2 we can get many grids from one */ /* file (one shared gridname). */ /* -------------------------------------------------------------------- */ - for( this_grid = grid_list; this_grid != NULL; this_grid = this_grid->next) + for( this_grid = grid_list; this_grid != nullptr; this_grid = this_grid->next) { if( strcmp(this_grid->gridname,gridname) == 0 ) { got_match = 1; /* don't add to the list if it is invalid. */ - if( this_grid->ct == NULL ) + if( this_grid->ct == nullptr ) return 0; /* do we need to grow the list? */ @@ -99,7 +99,7 @@ static int pj_gridlist_merge_gridfile( projCtx ctx, pj_ctx_set_errno( ctx, ENOMEM ); return 0; } - if( *p_gridlist != NULL ) + if( *p_gridlist != nullptr ) { memcpy( new_list, *p_gridlist, sizeof(void *) * (*p_gridmax) ); @@ -112,7 +112,7 @@ static int pj_gridlist_merge_gridfile( projCtx ctx, /* add to the list */ (*p_gridlist)[(*p_gridcount)++] = this_grid; - (*p_gridlist)[*p_gridcount] = NULL; + (*p_gridlist)[*p_gridcount] = nullptr; } tail = this_grid; @@ -126,12 +126,12 @@ static int pj_gridlist_merge_gridfile( projCtx ctx, /* -------------------------------------------------------------------- */ this_grid = pj_gridinfo_init( ctx, gridname ); - if( this_grid == NULL ) + if( this_grid == nullptr ) { return 0; } - if( tail != NULL ) + if( tail != nullptr ) tail->next = this_grid; else grid_list = this_grid; @@ -158,7 +158,7 @@ PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx ctx, const char *nadgrids, { const char *s; - PJ_GRIDINFO **gridlist = NULL; + PJ_GRIDINFO **gridlist = nullptr; int grid_max = 0; pj_errno = 0; @@ -190,7 +190,7 @@ PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx ctx, const char *nadgrids, pj_dalloc( gridlist ); pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); - return NULL; + return nullptr; } strncpy( name, s, end_char ); @@ -207,7 +207,7 @@ PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx ctx, const char *nadgrids, pj_dalloc( gridlist ); pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); - return NULL; + return nullptr; } else pj_errno = 0; diff --git a/src/pj_init.cpp b/src/pj_init.cpp index b09d70ed..5710031c 100644 --- a/src/pj_init.cpp +++ b/src/pj_init.cpp @@ -49,7 +49,7 @@ static paralist *string_to_paralist (PJ_CONTEXT *ctx, char *definition) { Convert a string (presumably originating from get_init_string) to a paralist. ***************************************************************************************/ char *c = definition; - paralist *first = 0, *next = 0; + paralist *first = nullptr, *next = nullptr; while (*c) { /* Find start of next substring */ @@ -57,11 +57,11 @@ static paralist *string_to_paralist (PJ_CONTEXT *ctx, char *definition) { c++; /* Keep a handle to the start of the list, so we have something to return */ - if (0==first) + if (nullptr==first) first = next = pj_mkparam_ws (c); else next = next->next = pj_mkparam_ws (c); - if (0==next) { + if (nullptr==next) { pj_dealloc_params (ctx, first, ENOMEM); return nullptr; } @@ -71,11 +71,11 @@ static paralist *string_to_paralist (PJ_CONTEXT *ctx, char *definition) { c++; } - if( next == 0 ) - return 0; + if( next == nullptr ) + return nullptr; /* Terminate list and return */ - next->next = 0; + next->next = nullptr; return first; } @@ -91,42 +91,42 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { size_t current_buffer_size = 5 * (MAX_LINE_LENGTH + 1); char *fname, *section; const char *key; - char *buffer = 0; - char *line = 0; + char *buffer = nullptr; + char *line = nullptr; PAFile fid; size_t n; line = static_cast<char*>(pj_malloc (MAX_LINE_LENGTH + 1)); - if (0==line) - return 0; + if (nullptr==line) + return nullptr; fname = static_cast<char*>(pj_malloc (MAX_PATH_FILENAME+ID_TAG_MAX+3)); - if (0==fname) { + if (nullptr==fname) { pj_dealloc (line); - return 0; + return nullptr; } /* Support "init=file:section", "+init=file:section", and "file:section" format */ key = strstr (name, "init="); - if (0==key) + if (nullptr==key) key = name; else key += 5; if (MAX_PATH_FILENAME + ID_TAG_MAX + 2 < strlen (key)) { pj_dealloc (fname); pj_dealloc (line); - return 0; + return nullptr; } memmove (fname, key, strlen (key) + 1); /* Locate the name of the section we search for */ section = strrchr(fname, ':'); - if (0==section) { + if (nullptr==section) { proj_context_errno_set (ctx, PJD_ERR_NO_COLON_IN_INIT_STRING); pj_dealloc (fname); pj_dealloc (line); - return 0; + return nullptr; } *section = 0; section++; @@ -136,24 +136,24 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { section, fname); fid = pj_open_lib (ctx, fname, "rt"); - if (0==fid) { + if (nullptr==fid) { pj_dealloc (fname); pj_dealloc (line); proj_context_errno_set (ctx, PJD_ERR_NO_OPTION_IN_INIT_FILE); - return 0; + return nullptr; } /* Search for section in init file */ for (;;) { /* End of file? */ - if (0==pj_ctx_fgets (ctx, line, MAX_LINE_LENGTH, fid)) { + if (nullptr==pj_ctx_fgets (ctx, line, MAX_LINE_LENGTH, fid)) { pj_dealloc (buffer); pj_dealloc (fname); pj_dealloc (line); pj_ctx_fclose (ctx, fid); proj_context_errno_set (ctx, PJD_ERR_NO_OPTION_IN_INIT_FILE); - return 0; + return nullptr; } /* At start of right section? */ @@ -170,11 +170,11 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { /* We're at the first line of the right section - copy line to buffer */ buffer = static_cast<char*>(pj_malloc (current_buffer_size)); - if (0==buffer) { + if (nullptr==buffer) { pj_dealloc (fname); pj_dealloc (line); pj_ctx_fclose (ctx, fid); - return 0; + return nullptr; } /* Skip the "<section>" indicator, and copy the rest of the line over */ @@ -193,7 +193,7 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { } /* End of file? - done! */ - if (0==pj_ctx_fgets (ctx, line, MAX_LINE_LENGTH, fid)) + if (nullptr==pj_ctx_fgets (ctx, line, MAX_LINE_LENGTH, fid)) break; /* Otherwise, handle the line. It MAY be the start of the next section, */ @@ -203,9 +203,9 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { next_length = strlen (line) + buffer_length + 2; if (next_length > current_buffer_size) { char *b = static_cast<char*>(pj_malloc (2 * current_buffer_size)); - if (0==b) { + if (nullptr==b) { pj_dealloc (buffer); - buffer = 0; + buffer = nullptr; break; } strcpy (b, buffer); @@ -220,8 +220,8 @@ static char *get_init_string (PJ_CONTEXT *ctx, const char *name) { pj_ctx_fclose (ctx, fid); pj_dealloc (fname); pj_dealloc (line); - if (0==buffer) - return 0; + if (nullptr==buffer) + return nullptr; pj_shrink (buffer); pj_log (ctx, PJ_LOG_TRACE, "key=%s, value: [%s]", key, buffer); return buffer; @@ -235,12 +235,12 @@ static paralist *get_init(PJ_CONTEXT *ctx, const char *key, int allow_init_epsg) Expand key from buffer or (if not in buffer) from init file *************************************************************************/ const char *xkey; - char *definition = 0; - paralist *init_items = 0; + char *definition = nullptr; + paralist *init_items = nullptr; /* support "init=file:section", "+init=file:section", and "file:section" format */ xkey = strstr (key, "init="); - if (0==xkey) + if (nullptr==xkey) xkey = key; else xkey += 5; @@ -270,7 +270,7 @@ Expand key from buffer or (if not in buffer) from init file } if( !exists ) { - const char* const optionsProj4Mode[] = { "USE_PROJ4_INIT_RULES=YES", NULL }; + const char* const optionsProj4Mode[] = { "USE_PROJ4_INIT_RULES=YES", nullptr }; char szInitStr[7 + 64]; PJ_OBJ* src; const char* proj_string; @@ -279,23 +279,23 @@ Expand key from buffer or (if not in buffer) from init file if( !allow_init_epsg ) { pj_log (ctx, PJ_LOG_TRACE, "%s expansion disallowed", xkey); - return 0; + return nullptr; } if( strlen(xkey) > 64 ) { - return 0; + return nullptr; } strcpy(szInitStr, "+init="); strcat(szInitStr, xkey); src = proj_obj_create_from_user_input(ctx, szInitStr, optionsProj4Mode); if( !src ) { - return 0; + return nullptr; } - proj_string = proj_obj_as_proj_string(ctx, src, PJ_PROJ_4, NULL); + proj_string = proj_obj_as_proj_string(ctx, src, PJ_PROJ_4, nullptr); if( !proj_string ) { proj_obj_destroy(src); - return 0; + return nullptr; } definition = (char*)calloc(1, strlen(proj_string)+1); if( definition ) { @@ -313,8 +313,8 @@ Expand key from buffer or (if not in buffer) from init file definition = get_init_string (ctx, xkey); } - if (0==definition) - return 0; + if (nullptr==definition) + return nullptr; init_items = string_to_paralist (ctx, definition); if (init_items) pj_log (ctx, PJ_LOG_TRACE, "get_init: got [%s], paralist[0,1]: [%s,%s]", @@ -322,8 +322,8 @@ Expand key from buffer or (if not in buffer) from init file init_items->param, init_items->next ? init_items->next->param : "(empty)"); pj_dealloc (definition); - if (0==init_items) - return 0; + if (nullptr==init_items) + return nullptr; /* We found it in file - now insert into the cache, before returning */ pj_insert_initcache (xkey, init_items); @@ -333,23 +333,23 @@ Expand key from buffer or (if not in buffer) from init file static paralist *append_defaults_to_paralist (PJ_CONTEXT *ctx, paralist *start, const char *key, int allow_init_epsg) { - paralist *defaults, *last = 0; + paralist *defaults, *last = nullptr; char keystring[ID_TAG_MAX + 20]; paralist *next, *proj; int err; - if (0==start) - return 0; + if (nullptr==start) + return nullptr; if (strlen(key) > ID_TAG_MAX) - return 0; + return nullptr; /* Set defaults, unless inhibited (either explicitly through a "no_defs" token */ /* or implicitly, because we are initializing a pipeline) */ if (pj_param_exists (start, "no_defs")) return start; proj = pj_param_exists (start, "proj"); - if (0==proj) + if (nullptr==proj) return start; if (strlen (proj->param) < 6) return start; @@ -394,7 +394,7 @@ static paralist *append_defaults_to_paralist (PJ_CONTEXT *ctx, paralist *start, /* If we're here, it's OK to append the current default item */ last = last->next = pj_mkparam(next->param); } - last->next = 0; + last->next = nullptr; pj_dealloc_params (ctx, defaults, 0); return last; @@ -425,14 +425,14 @@ Note that 'init=foo:bar' stays in the list. It is ignored after expansion. paralist *expn; /* Nowhere to start? */ - if (0==init) - return 0; + if (nullptr==init) + return nullptr; expn = get_init(ctx, init->param, allow_init_epsg); /* Nothing in expansion? */ - if (0==expn) - return 0; + if (nullptr==expn) + return nullptr; /* Locate the end of the list */ for (last = init; last && last->next; last = last->next); @@ -469,12 +469,12 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) char *argv[MAX_ARG]; char *defn_copy; int argc = 0, i, blank_count = 0; - PJ *result = NULL; + PJ *result = nullptr; /* make a copy that we can manipulate */ defn_copy = (char *) pj_malloc( strlen(definition)+1 ); if (!defn_copy) - return NULL; + return nullptr; strcpy( defn_copy, definition ); /* split into arguments based on '+' and trim white space */ @@ -497,7 +497,7 @@ pj_init_plus_ctx( projCtx ctx, const char *definition ) { pj_dalloc( defn_copy ); pj_ctx_set_errno( ctx, PJD_ERR_UNPARSEABLE_CS_DEF ); - return 0; + return nullptr; } argv[argc++] = defn_copy + i + 1; @@ -552,8 +552,8 @@ static PJ_CONSTRUCTOR locate_constructor (const char *name) { const PJ_OPERATIONS *operations; operations = proj_list_operations(); for (i = 0; (s = operations[i].id) && strcmp(name, s) ; ++i) ; - if (0==s) - return 0; + if (nullptr==s) + return nullptr; return (PJ_CONSTRUCTOR) operations[i].proj; } @@ -574,20 +574,20 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i paralist *curr, *init, *start; int i; int err; - PJ *PIN = 0; + PJ *PIN = nullptr; int n_pipelines = 0; int n_inits = 0; const PJ_UNITS *units; const PJ_PRIME_MERIDIANS *prime_meridians; - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx (); ctx->last_errno = 0; if (argc <= 0) { pj_ctx_set_errno (ctx, PJD_ERR_NO_ARGS); - return 0; + return nullptr; } /* count occurrences of pipelines and inits */ @@ -601,13 +601,13 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* can't have nested pipelines directly */ if (n_pipelines > 1) { pj_ctx_set_errno (ctx, PJD_ERR_MALFORMED_PIPELINE); - return 0; + return nullptr; } /* don't allow more than one +init in non-pipeline operations */ if (n_pipelines == 0 && n_inits > 1) { pj_ctx_set_errno (ctx, PJD_ERR_TOO_MANY_INITS); - return 0; + return nullptr; } @@ -647,7 +647,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* Find projection selection */ curr = pj_param_exists (start, "proj"); - if (0==curr) { + if (nullptr==curr) { pj_dealloc_params (ctx, start, PJD_ERR_PROJ_NOT_NAMED); return nullptr; } @@ -659,7 +659,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i name += 5; proj = locate_constructor (name); - if (0==proj) { + if (nullptr==proj) { pj_dealloc_params (ctx, start, PJD_ERR_UNKNOWN_PROJECTION_ID); return nullptr; } @@ -671,8 +671,8 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* Allocate projection structure */ - PIN = proj(0); - if (0==PIN) { + PIN = proj(nullptr); + if (nullptr==PIN) { pj_dealloc_params (ctx, start, ENOMEM); return nullptr; } @@ -686,10 +686,10 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i PIN->long_wrap_center = 0.0; strcpy( PIN->axis, "enu" ); - PIN->gridlist = NULL; + PIN->gridlist = nullptr; PIN->gridlist_count = 0; - PIN->vgridlist_geoid = NULL; + PIN->vgridlist_geoid = nullptr; PIN->vgridlist_geoid_count = 0; /* Set datum parameters. Similarly to +init parameters we want to expand */ @@ -755,16 +755,16 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i } /* Axis orientation */ - if( (pj_param(ctx, start,"saxis").s) != NULL ) + if( (pj_param(ctx, start,"saxis").s) != nullptr ) { const char *axis_legal = "ewnsud"; const char *axis_arg = pj_param(ctx, start,"saxis").s; if( strlen(axis_arg) != 3 ) return pj_default_destructor (PIN, PJD_ERR_AXIS); - if( strchr( axis_legal, axis_arg[0] ) == NULL - || strchr( axis_legal, axis_arg[1] ) == NULL - || strchr( axis_legal, axis_arg[2] ) == NULL) + if( strchr( axis_legal, axis_arg[0] ) == nullptr + || strchr( axis_legal, axis_arg[1] ) == nullptr + || strchr( axis_legal, axis_arg[2] ) == nullptr) return pj_default_destructor (PIN, PJD_ERR_AXIS); /* TODO: it would be nice to validate we don't have on axis repeated */ @@ -795,8 +795,8 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* Set units */ units = proj_list_units(); - s = 0; - if ((name = pj_param(ctx, start, "sunits").s) != NULL) { + s = nullptr; + if ((name = pj_param(ctx, start, "sunits").s) != nullptr) { for (i = 0; (s = units[i].id) && strcmp(name, s) ; ++i) ; if (!s) return pj_default_destructor (PIN, PJD_ERR_UNKNOWN_UNIT_ID); @@ -812,7 +812,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i s += 2; } - factor = pj_strtod(s, 0); + factor = pj_strtod(s, nullptr); if ((factor <= 0.0) || (1/factor==0)) return pj_default_destructor (PIN, PJD_ERR_UNIT_FACTOR_LESS_THAN_0); @@ -823,17 +823,17 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i PIN->to_meter = PIN->fr_meter = 1.; /* Set vertical units */ - s = 0; - if ((name = pj_param(ctx, start, "svunits").s) != NULL) { + s = nullptr; + if ((name = pj_param(ctx, start, "svunits").s) != nullptr) { for (i = 0; (s = units[i].id) && strcmp(name, s) ; ++i) ; if (!s) return pj_default_destructor (PIN, PJD_ERR_UNKNOWN_UNIT_ID); s = units[i].to_meter; } if (s || (s = pj_param(ctx, start, "svto_meter").s)) { - PIN->vto_meter = pj_strtod(s, 0); + PIN->vto_meter = pj_strtod(s, nullptr); if (*s == '/') /* ratio number */ - PIN->vto_meter /= pj_strtod(++s, 0); + PIN->vto_meter /= pj_strtod(++s, nullptr); if (PIN->vto_meter <= 0.0) return pj_default_destructor (PIN, PJD_ERR_UNIT_FACTOR_LESS_THAN_0); PIN->vfr_meter = 1. / PIN->vto_meter; @@ -844,12 +844,12 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i /* Prime meridian */ prime_meridians = proj_list_prime_meridians(); - s = 0; - if ((name = pj_param(ctx, start, "spm").s) != NULL) { - const char *value = NULL; - char *next_str = NULL; + s = nullptr; + if ((name = pj_param(ctx, start, "spm").s) != nullptr) { + const char *value = nullptr; + char *next_str = nullptr; - for (i = 0; prime_meridians[i].id != NULL; ++i ) + for (i = 0; prime_meridians[i].id != nullptr; ++i ) { if( strcmp(name,prime_meridians[i].id) == 0 ) { @@ -858,21 +858,21 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i } } - if( value == NULL + if( value == nullptr && (dmstor_ctx(ctx,name,&next_str) != 0.0 || *name == '0') && *next_str == '\0' ) value = name; if (!value) return pj_default_destructor (PIN, PJD_ERR_UNKNOWN_PRIME_MERIDIAN); - PIN->from_greenwich = dmstor_ctx(ctx,value,NULL); + PIN->from_greenwich = dmstor_ctx(ctx,value,nullptr); } else PIN->from_greenwich = 0.0; /* Private object for the geodesic functions */ PIN->geod = static_cast<struct geod_geodesic*>(pj_calloc (1, sizeof (struct geod_geodesic))); - if (0==PIN->geod) + if (nullptr==PIN->geod) return pj_default_destructor (PIN, ENOMEM); geod_init(PIN->geod, PIN->a, (1 - sqrt (1 - PIN->es))); @@ -881,7 +881,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i PIN = proj(PIN); if (proj_errno (PIN)) { pj_free(PIN); - return 0; + return nullptr; } proj_errno_restore (PIN, err); return PIN; diff --git a/src/pj_initcache.cpp b/src/pj_initcache.cpp index 3c347e4b..052a016c 100644 --- a/src/pj_initcache.cpp +++ b/src/pj_initcache.cpp @@ -31,8 +31,8 @@ static int cache_count = 0; static int cache_alloc = 0; -static char **cache_key = NULL; -static paralist **cache_paralist = NULL; +static char **cache_key = nullptr; +static paralist **cache_paralist = nullptr; /************************************************************************/ /* pj_clone_paralist() */ @@ -42,18 +42,18 @@ static paralist **cache_paralist = NULL; paralist *pj_clone_paralist( const paralist *list) { - paralist *list_copy = NULL, *next_copy = NULL; + paralist *list_copy = nullptr, *next_copy = nullptr; - for( ; list != NULL; list = list->next ) + for( ; list != nullptr; list = list->next ) { paralist *newitem = (paralist *) pj_malloc(sizeof(paralist) + strlen(list->param)); newitem->used = 0; - newitem->next = 0; + newitem->next = nullptr; strcpy( newitem->param, list->param ); - if( list_copy == NULL ) + if( list_copy == nullptr ) list_copy = newitem; else next_copy->next = newitem; @@ -85,7 +85,7 @@ void pj_clear_initcache() pj_dalloc( cache_key[i] ); /* free parameter list elements */ - for (; t != NULL; t = n) { + for (; t != nullptr; t = n) { n = t->next; pj_dalloc(t); } @@ -95,8 +95,8 @@ void pj_clear_initcache() pj_dalloc( cache_paralist ); cache_count = 0; cache_alloc= 0; - cache_key = NULL; - cache_paralist = NULL; + cache_key = nullptr; + cache_paralist = nullptr; pj_release_lock(); } @@ -112,11 +112,11 @@ paralist *pj_search_initcache( const char *filekey ) { int i; - paralist *result = NULL; + paralist *result = nullptr; pj_acquire_lock(); - for( i = 0; result == NULL && i < cache_count; i++) + for( i = 0; result == nullptr && i < cache_count; i++) { if( strcmp(filekey,cache_key[i]) == 0 ) { diff --git a/src/pj_internal.cpp b/src/pj_internal.cpp index ac9fe1e0..3f3d191e 100644 --- a/src/pj_internal.cpp +++ b/src/pj_internal.cpp @@ -73,7 +73,7 @@ Behave mostly as proj_trans, but attempt to use 2D interfaces only. Used in gie.c, to enforce testing 2D code, and by PJ_pipeline.c to implement chained calls starting out with a call to its 2D interface. ***************************************************************************************/ - if (0==P) + if (nullptr==P) return coo; if (P->inverted) direction = static_cast<PJ_DIRECTION>(-direction); @@ -103,7 +103,7 @@ Behave mostly as proj_trans, but attempt to use 3D interfaces only. Used in gie.c, to enforce testing 3D code, and by PJ_pipeline.c to implement chained calls starting out with a call to its 3D interface. ***************************************************************************************/ - if (0==P) + if (nullptr==P) return coo; if (P->inverted) direction = static_cast<PJ_DIRECTION>(-direction); @@ -135,14 +135,14 @@ Check if a a PJ has an inverse. /* Move P to a new context - or to the default context if 0 is specified */ void proj_context_set (PJ *P, PJ_CONTEXT *ctx) { - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx (); pj_set_ctx (P, ctx); } void proj_context_inherit (PJ *parent, PJ *child) { - if (0==parent) + if (nullptr==parent) pj_set_ctx (child, pj_get_default_ctx()); else pj_set_ctx (child, pj_get_ctx(parent)); @@ -160,8 +160,8 @@ considered whitespace. char *comment; char *start = c; - if (0==c) - return 0; + if (nullptr==c) + return nullptr; comment = strchr (c, '#'); if (comment) @@ -202,8 +202,8 @@ consuming their surrounding whitespace. /* Flag showing that a whitespace (ws) has been written after last non-ws */ size_t ws; - if (0==c) - return 0; + if (nullptr==c) + return nullptr; pj_chomp (c); n = strlen (c); @@ -303,16 +303,16 @@ It is the duty of the caller to free this array. size_t i, j; char **argv; - if (0==args) - return 0; + if (nullptr==args) + return nullptr; if (0==argc) - return 0; + return nullptr; /* turn the input string into an array of strings */ argv = (char **) calloc (argc, sizeof (char *)); - if (0==argv) - return 0; + if (nullptr==argv) + return nullptr; argv[0] = args; j = 1; for (i = 0; ; i++) { @@ -344,8 +344,8 @@ array. n += strlen (argv[i]); p = static_cast<char*>(pj_calloc (n + argc + 1, sizeof (char))); - if (0==p) - return 0; + if (nullptr==p) + return nullptr; if (0==argc) return p; @@ -364,7 +364,7 @@ void proj_context_errno_set (PJ_CONTEXT *ctx, int err) { Raise an error directly on a context, without going through a PJ belonging to that context. ******************************************************************************/ - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx(); pj_ctx_set_errno (ctx, err); } @@ -381,9 +381,9 @@ PJ_LOG_LEVEL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL log_level) { Set logging level 0-3. Higher number means more debug info. 0 turns it off ****************************************************************************************/ PJ_LOG_LEVEL previous; - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx(); - if (0==ctx) + if (nullptr==ctx) return PJ_LOG_TELL; previous = static_cast<PJ_LOG_LEVEL>(abs (ctx->debug_level)); if (PJ_LOG_TELL==log_level) @@ -435,11 +435,11 @@ void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf) { Put a new logging function into P's context. The opaque object app_data is passed as first arg at each call to the logger ******************************************************************************/ - if (0==ctx) + if (nullptr==ctx) pj_get_default_ctx (); - if (0==ctx) + if (nullptr==ctx) return; ctx->app_data = app_data; - if (0!=logf) + if (nullptr!=logf) ctx->logger = logf; } diff --git a/src/pj_inv.cpp b/src/pj_inv.cpp index aaa8fea9..ba7e6722 100644 --- a/src/pj_inv.cpp +++ b/src/pj_inv.cpp @@ -114,7 +114,7 @@ static PJ_COORD inv_finalize (PJ *P, PJ_COORD coo) { return coo; if (P->hgridshift) coo = proj_trans (P->hgridshift, PJ_FWD, coo); - else if (P->helmert || (P->cart_wgs84 != 0 && P->cart != 0)) { + else if (P->helmert || (P->cart_wgs84 != nullptr && P->cart != nullptr)) { coo = proj_trans (P->cart, PJ_FWD, coo); /* Go cartesian in local frame */ if( P->helmert ) coo = proj_trans (P->helmert, PJ_FWD, coo); /* Step into WGS84 */ diff --git a/src/pj_list.cpp b/src/pj_list.cpp index 55ea36c2..73ca5f86 100644 --- a/src/pj_list.cpp +++ b/src/pj_list.cpp @@ -22,7 +22,7 @@ #define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id}, const struct PJ_LIST pj_list[] = { #include "pj_list.h" - {0, 0, 0}, + {nullptr, nullptr, nullptr}, }; #undef PROJ_HEAD diff --git a/src/pj_log.cpp b/src/pj_log.cpp index 6654691c..0f81dc13 100644 --- a/src/pj_log.cpp +++ b/src/pj_log.cpp @@ -68,7 +68,7 @@ void pj_vlog( projCtx ctx, int level, const char *fmt, va_list args ) return; msg_buf = (char *) malloc(100000); - if( msg_buf == NULL ) + if( msg_buf == nullptr ) return; /* we should use vsnprintf where available once we add configure detect.*/ diff --git a/src/pj_malloc.cpp b/src/pj_malloc.cpp index 66977cf4..c8681570 100644 --- a/src/pj_malloc.cpp +++ b/src/pj_malloc.cpp @@ -95,8 +95,8 @@ It allocates space for an array of <n> elements of size <size>. The array is initialized to zeros. ***********************************************************************/ void *res = pj_malloc (n*size); - if (0==res) - return 0; + if (nullptr==res) + return nullptr; memset (res, 0, n*size); return res; } @@ -128,10 +128,10 @@ pointer" to signal an error in a multi level allocation: return p; // success ***********************************************************************/ - if (0==ptr) - return 0; + if (nullptr==ptr) + return nullptr; pj_dalloc (ptr); - return 0; + return nullptr; } /**********************************************************************/ @@ -161,7 +161,7 @@ void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) { pj_dealloc(t); } pj_ctx_set_errno (ctx, errlev); - return (void *) 0; + return (void *) nullptr; } @@ -178,7 +178,7 @@ void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) { /************************************************************************/ void pj_free(PJ *P) { - if (0==P) + if (nullptr==P) return; /* free projection parameters - all the hard work is done by */ /* pj_default_destructor, which is supposed */ @@ -205,8 +205,8 @@ PJ *pj_default_destructor (PJ *P, int errlev) { /* Destructor */ if (0!=errlev) pj_ctx_set_errno (pj_get_ctx(P), errlev); - if (0==P) - return 0; + if (nullptr==P) + return nullptr; /* free grid lists */ pj_dealloc( P->gridlist ); diff --git a/src/pj_mlfn.cpp b/src/pj_mlfn.cpp index 02e05c3a..e032e642 100644 --- a/src/pj_mlfn.cpp +++ b/src/pj_mlfn.cpp @@ -27,8 +27,8 @@ double *pj_enfn(double es) { double t, *en; en = (double *) pj_malloc(EN_SIZE * sizeof (double)); - if (0==en) - return 0; + if (nullptr==en) + return nullptr; en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08))); en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08))); diff --git a/src/pj_mutex.cpp b/src/pj_mutex.cpp index dc4a441b..61487cec 100644 --- a/src/pj_mutex.cpp +++ b/src/pj_mutex.cpp @@ -106,7 +106,14 @@ void pj_cleanup_lock() #include "pthread.h" #ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" +#endif static pthread_mutex_t core_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif #else static pthread_mutex_t core_lock; diff --git a/src/pj_open_lib.cpp b/src/pj_open_lib.cpp index 31a2c2e1..c75b4af6 100644 --- a/src/pj_open_lib.cpp +++ b/src/pj_open_lib.cpp @@ -39,14 +39,14 @@ #include "proj_internal.h" #include "projects.h" -static const char *(*pj_finder)(const char *) = NULL; +static const char *(*pj_finder)(const char *) = nullptr; static int path_count = 0; -static char **search_path = NULL; +static char **search_path = nullptr; static const char * proj_lib_name = #ifdef PROJ_LIB PROJ_LIB; #else -0; +nullptr; #endif /************************************************************************/ @@ -71,7 +71,7 @@ void pj_set_searchpath ( int count, const char **path ) { int i; - if (path_count > 0 && search_path != NULL) + if (path_count > 0 && search_path != nullptr) { for (i = 0; i < path_count; i++) { @@ -79,7 +79,7 @@ void pj_set_searchpath ( int count, const char **path ) } pj_dalloc(search_path); path_count = 0; - search_path = NULL; + search_path = nullptr; } if( count > 0 ) @@ -122,15 +122,15 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, static const char dir_chars[] = "/"; #endif - if( out_full_filename != NULL && out_full_filename_size > 0 ) + if( out_full_filename != nullptr && out_full_filename_size > 0 ) out_full_filename[0] = '\0'; /* check if ~/name */ if (*name == '~' && strchr(dir_chars,name[1]) ) - if ((sysname = getenv("HOME")) != NULL) { + if ((sysname = getenv("HOME")) != nullptr) { if( strlen(sysname) + 1 + strlen(name) + 1 > sizeof(fname) ) { - return NULL; + return nullptr; } (void)strcpy(fname, sysname); fname[n = (int)strlen(fname)] = DIR_CHAR; @@ -138,7 +138,7 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, (void)strcpy(fname+n, name + 1); sysname = fname; } else - return NULL; + return nullptr; /* or fixed path: /name, ./name or ../name */ else if (strchr(dir_chars,*name) @@ -148,14 +148,14 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, sysname = name; /* or try to use application provided file finder */ - else if( pj_finder != NULL && pj_finder( name ) != NULL ) + else if( pj_finder != nullptr && pj_finder( name ) != nullptr ) sysname = pj_finder( name ); /* or is environment PROJ_LIB defined */ else if ((sysname = getenv("PROJ_LIB")) || (sysname = proj_lib_name)) { if( strlen(sysname) + 1 + strlen(name) + 1 > sizeof(fname) ) { - return NULL; + return nullptr; } (void)strcpy(fname, sysname); fname[n = (int)strlen(fname)] = DIR_CHAR; @@ -165,9 +165,9 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, } else /* just try it bare bones */ sysname = name; - if ((fid = pj_ctx_fopen(ctx, sysname, mode)) != NULL) + if ((fid = pj_ctx_fopen(ctx, sysname, mode)) != nullptr) { - if( out_full_filename != NULL && out_full_filename_size > 0 ) + if( out_full_filename != nullptr && out_full_filename_size > 0 ) { strncpy(out_full_filename, sysname, out_full_filename_size); out_full_filename[out_full_filename_size-1] = '\0'; @@ -178,7 +178,7 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, /* If none of those work and we have a search path, try it */ if (!fid && path_count > 0) { - for (i = 0; fid == NULL && i < path_count; i++) + for (i = 0; fid == nullptr && i < path_count; i++) { if( strlen(search_path[i]) + 1 + strlen(name) + 1 <= sizeof(fname) ) { @@ -189,7 +189,7 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, } if (fid) { - if( out_full_filename != NULL && out_full_filename_size > 0 ) + if( out_full_filename != nullptr && out_full_filename_size > 0 ) { strncpy(out_full_filename, sysname, out_full_filename_size); out_full_filename[out_full_filename_size-1] = '\0'; @@ -204,7 +204,7 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, pj_log( ctx, PJ_LOG_DEBUG_MAJOR, "pj_open_lib(%s): call fopen(%s) - %s", name, sysname, - fid == NULL ? "failed" : "succeeded" ); + fid == nullptr ? "failed" : "succeeded" ); return(fid); } @@ -215,7 +215,7 @@ pj_open_lib_ex(projCtx ctx, const char *name, const char *mode, PAFile pj_open_lib(projCtx ctx, const char *name, const char *mode) { - return pj_open_lib_ex(ctx, name, mode, NULL, 0); + return pj_open_lib_ex(ctx, name, mode, nullptr, 0); } /************************************************************************/ @@ -238,7 +238,7 @@ int pj_find_file(projCtx ctx, const char *short_filename, { PAFile f = pj_open_lib_ex(ctx, short_filename, "rb", out_full_filename, out_full_filename_size); - if( f != NULL ) + if( f != nullptr ) { pj_ctx_fclose(ctx, f); return 1; diff --git a/src/pj_param.cpp b/src/pj_param.cpp index 1887afe9..74247b72 100644 --- a/src/pj_param.cpp +++ b/src/pj_param.cpp @@ -12,9 +12,9 @@ paralist *pj_mkparam(const char *str) { paralist *newitem; - if((newitem = (paralist *)pj_malloc(sizeof(paralist) + strlen(str))) != NULL) { + if((newitem = (paralist *)pj_malloc(sizeof(paralist) + strlen(str))) != nullptr) { newitem->used = 0; - newitem->next = 0; + newitem->next = nullptr; if (*str == '+') ++str; (void)strcpy(newitem->param, str); @@ -28,8 +28,8 @@ paralist *pj_mkparam_ws (const char *str) { paralist *newitem; size_t len = 0; - if (0==str) - return 0; + if (nullptr==str) + return nullptr; /* Find start and length of string */ while (isspace (*str)) @@ -43,12 +43,12 @@ paralist *pj_mkparam_ws (const char *str) { /* Use calloc to automagically 0-terminate the copy */ newitem = (paralist *) pj_calloc (1, sizeof(paralist) + len + 1); - if (0==newitem) - return 0; + if (nullptr==newitem) + return nullptr; memmove(newitem->param, str, len); newitem->used = 0; - newitem->next = 0; + newitem->next = nullptr; return newitem; } @@ -74,8 +74,8 @@ paralist *pj_param_exists (paralist *list, const char *parameter) { size_t len = strlen (parameter); if (c) len = c - parameter; - if (list==0) - return 0; + if (list==nullptr) + return nullptr; for (next = list; next; next = next->next) { if (0==strncmp (parameter, next->param, len) && (next->param[len]=='=' || next->param[len]==0)) { @@ -83,10 +83,10 @@ paralist *pj_param_exists (paralist *list, const char *parameter) { return next; } if (0==strcmp (parameter, "step")) - return 0; + return nullptr; } - return 0; + return nullptr; } @@ -116,24 +116,24 @@ PROJVALUE pj_param (projCtx ctx, paralist *pl, const char *opt) { unsigned l; PROJVALUE value = {0}; - if ( ctx == NULL ) + if ( ctx == nullptr ) ctx = pj_get_default_ctx(); type = *opt++; - if (0==strchr ("tbirds", type)) { + if (nullptr==strchr ("tbirds", type)) { fprintf(stderr, "invalid request to pj_param, fatal\n"); exit(1); } pl = pj_param_exists (pl, opt); if (type == 't') { - value.i = pl != 0; + value.i = pl != nullptr; return value; } /* Not found */ - if (0==pl) { + if (nullptr==pl) { /* Return value after the switch, so that the return path is */ /* taken in all cases */ switch (type) { @@ -144,7 +144,7 @@ PROJVALUE pj_param (projCtx ctx, paralist *pl, const char *opt) { value.f = 0.; break; case 's': - value.s = 0; + value.s = nullptr; break; } return value; @@ -165,7 +165,7 @@ PROJVALUE pj_param (projCtx ctx, paralist *pl, const char *opt) { value.f = pj_atof(opt); break; case 'r': /* degrees input */ - value.f = dmstor_ctx(ctx, opt, 0); + value.f = dmstor_ctx(ctx, opt, nullptr); break; case 's': /* char string */ value.s = (char *) opt; diff --git a/src/pj_pr_list.cpp b/src/pj_pr_list.cpp index 4e71e471..b8ad2c04 100644 --- a/src/pj_pr_list.cpp +++ b/src/pj_pr_list.cpp @@ -67,7 +67,7 @@ char *pj_get_def( PJ *P, int options ) definition = (char *) pj_malloc(def_max); if (!definition) - return NULL; + return nullptr; definition[0] = '\0'; for (t = P->params; t; t = t->next) @@ -91,7 +91,7 @@ char *pj_get_def( PJ *P, int options ) } else { pj_dalloc( definition ); - return NULL; + return nullptr; } } diff --git a/src/pj_strerrno.cpp b/src/pj_strerrno.cpp index 16042f79..18ed0d33 100644 --- a/src/pj_strerrno.cpp +++ b/src/pj_strerrno.cpp @@ -79,7 +79,7 @@ char *pj_strerrno(int err) { size_t adjusted_err; if (0==err) - return 0; + return nullptr; /* System error codes are positive */ if (err > 0) { diff --git a/src/pj_strtod.cpp b/src/pj_strtod.cpp index f604a013..5a360c2e 100644 --- a/src/pj_strtod.cpp +++ b/src/pj_strtod.cpp @@ -65,7 +65,7 @@ */ double pj_atof( const char* nptr ) { - return pj_strtod(nptr, NULL); + return pj_strtod(nptr, nullptr); } @@ -134,7 +134,7 @@ static char* replace_point_by_locale_point(const char* pszNumber, char point, else { pszNew = pj_strdup(pszNumber); if (!pszNew) - return NULL; + return nullptr; } if( pszLocalePoint ) pszNew[pszLocalePoint - pszNumber] = ' '; diff --git a/src/pj_transform.cpp b/src/pj_transform.cpp index 53429967..7a73a65e 100644 --- a/src/pj_transform.cpp +++ b/src/pj_transform.cpp @@ -140,7 +140,7 @@ static int geographic_to_cartesian (PJ *P, PJ_DIRECTION dir, long n, int dist, d if (!P->is_geocent) return 0; - if ( z == NULL ) { + if ( z == nullptr ) { pj_ctx_set_errno( pj_get_ctx(P), PJD_ERR_GEOCENTRIC); return PJD_ERR_GEOCENTRIC; } @@ -195,10 +195,10 @@ static int geographic_to_projected (PJ *P, long n, int dist, double *x, double * if (P->is_geocent) return 0; - if(P->fwd3d != NULL && !(z == NULL && P->is_latlong)) + if(P->fwd3d != nullptr && !(z == nullptr && P->is_latlong)) { /* Three dimensions must be defined */ - if ( z == NULL) + if ( z == nullptr) { pj_ctx_set_errno( pj_get_ctx(P), PJD_ERR_GEOCENTRIC); return PJD_ERR_GEOCENTRIC; @@ -296,7 +296,7 @@ static int projected_to_geographic (PJ *P, long n, int dist, double *x, double * return 0; /* Check first if projection is invertible. */ - if( (P->inv3d == NULL) && (P->inv == NULL)) + if( (P->inv3d == nullptr) && (P->inv == nullptr)) { pj_ctx_set_errno(pj_get_ctx(P), PJD_ERR_NON_CONV_INV_MERI_DIST); pj_log( pj_get_ctx(P), PJ_LOG_ERROR, @@ -305,10 +305,10 @@ static int projected_to_geographic (PJ *P, long n, int dist, double *x, double * } /* If invertible - First try inv3d if defined */ - if (P->inv3d != NULL && !(z == NULL && P->is_latlong)) + if (P->inv3d != nullptr && !(z == nullptr && P->is_latlong)) { /* Three dimensions must be defined */ - if ( z == NULL) + if ( z == nullptr) { pj_ctx_set_errno( pj_get_ctx(P), PJD_ERR_GEOCENTRIC); return PJD_ERR_GEOCENTRIC; @@ -430,7 +430,7 @@ static int height_unit (PJ *P, PJ_DIRECTION dir, long n, int dist, double *z) { /* Nothing to do? */ if (fac==1.0) return 0; - if (0==z) + if (nullptr==z) return 0; if (P->is_latlong) return 0; /* done in pj_inv3d() / pj_fwd3d() */ @@ -451,7 +451,7 @@ static int geometric_to_orthometric (PJ *P, PJ_DIRECTION dir, long n, int dist, int err; if (0==P->has_geoid_vgrids) return 0; - if (z==0) + if (z==nullptr) return PJD_ERR_GEOCENTRIC; err = pj_apply_vgridshift (P, "sgeoidgrids", &(P->vgridlist_geoid), @@ -713,7 +713,7 @@ int pj_compare_datums( PJ *srcdefn, PJ *dstdefn ) pj_param(srcdefn->ctx, srcdefn->params,"snadgrids").s; const char* dstnadgrids = pj_param(dstdefn->ctx, dstdefn->params,"snadgrids").s; - return srcnadgrids != 0 && dstnadgrids != 0 && + return srcnadgrids != nullptr && dstnadgrids != nullptr && strcmp( srcnadgrids, dstnadgrids ) == 0; } else @@ -859,7 +859,7 @@ int pj_datum_transform( PJ *src, PJ *dst, /* -------------------------------------------------------------------- */ /* Create a temporary Z array if one is not provided. */ /* -------------------------------------------------------------------- */ - if( z == NULL ) + if( z == nullptr ) { size_t bytes = sizeof(double) * point_count * point_offset; z = (double *) pj_malloc(bytes); @@ -1024,7 +1024,7 @@ static int adjust_axis( projCtx ctx, { double *target; - if( i_axis == 2 && z == NULL ) + if( i_axis == 2 && z == nullptr ) continue; if( i_axis == 0 ) diff --git a/src/pj_units.cpp b/src/pj_units.cpp index 877758a3..50f11396 100644 --- a/src/pj_units.cpp +++ b/src/pj_units.cpp @@ -33,7 +33,7 @@ pj_units[] = { {"ind-yd", "0.91439523", "Indian Yard", 0.91439523}, {"ind-ft", "0.30479841", "Indian Foot", 0.30479841}, {"ind-ch", "20.11669506", "Indian Chain", 20.11669506}, - {NULL, NULL, NULL, 0.0} + {nullptr, nullptr, nullptr, 0.0} }; const PJ_UNITS *proj_list_units() @@ -49,7 +49,7 @@ pj_angular_units[] = { {"rad", "1.0", "Radian", 1.0}, {"deg", "0.017453292519943296", "Degree", DEG_TO_RAD}, {"grad", "0.015707963267948967", "Grad", GRAD_TO_RAD}, - {NULL, NULL, NULL, 0.0} + {nullptr, nullptr, nullptr, 0.0} }; const PJ_UNITS *proj_list_angular_units() diff --git a/src/pj_utils.cpp b/src/pj_utils.cpp index 81a80b45..8587dc30 100644 --- a/src/pj_utils.cpp +++ b/src/pj_utils.cpp @@ -43,7 +43,7 @@ int pj_is_latlong( PJ *pj ) { - return pj == NULL || pj->is_latlong; + return pj == nullptr || pj->is_latlong; } /************************************************************************/ @@ -55,7 +55,7 @@ int pj_is_latlong( PJ *pj ) int pj_is_geocent( PJ *pj ) { - return pj != NULL && pj->is_geocent; + return pj != nullptr && pj->is_geocent; } /************************************************************************/ @@ -118,7 +118,7 @@ PJ *pj_latlong_from_proj( PJ *pj_in ) { pj_ctx_set_errno( pj_in->ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN ); - return NULL; + return nullptr; } if( !got_datum ) diff --git a/src/proj.cpp b/src/proj.cpp index 2405781c..8bb29c31 100644 --- a/src/proj.cpp +++ b/src/proj.cpp @@ -44,7 +44,7 @@ static int static char *cheby_str, /* string controlling Chebychev evaluation */ - *oform = (char *)0, /* output format for x-y or decimal degrees */ + *oform = (char *)nullptr, /* output format for x-y or decimal degrees */ oform_buffer[16]; /* Buffer for oform when using -d */ static const char @@ -74,7 +74,7 @@ static projUV int_proj(projUV data) { /* file processing function */ static void process(FILE *fid) { - char line[MAX_LINE+3], *s = 0, pline[40]; + char line[MAX_LINE+3], *s = nullptr, pline[40]; PJ_COORD data; for (;;) { @@ -313,7 +313,7 @@ int main(int argc, char **argv) { FILE *fid; int pargc = 0, iargc = argc, eargc = 0, mon = 0; - if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != NULL) + if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != nullptr) ++emess_dat.Prog_name; else emess_dat.Prog_name = *argv; inverse = ! strncmp(emess_dat.Prog_name, "inv", 3); @@ -410,7 +410,7 @@ int main(int argc, char **argv) { { printf("%12s %-12s %-30s\n", ld->id, ld->ellipse_id, ld->defn); - if( ld->comments != NULL && strlen(ld->comments) > 0 ) + if( ld->comments != nullptr && strlen(ld->comments) > 0 ) printf( "%25s %s\n", " ", ld->comments ); } } else @@ -559,7 +559,7 @@ int main(int argc, char **argv) { } } else { - if ((fid = fopen(*eargv, "rb")) == NULL) { + if ((fid = fopen(*eargv, "rb")) == nullptr) { emess(-2, *eargv, "input file"); continue; } @@ -571,7 +571,7 @@ int main(int argc, char **argv) { else process(fid); (void)fclose(fid); - emess_dat.File_name = 0; + emess_dat.File_name = nullptr; } if( Proj ) @@ -331,7 +331,11 @@ typedef struct projCtx_t PJ_CONTEXT; /* Functionality for handling thread contexts */ +#ifdef __cplusplus +#define PJ_DEFAULT_CTX nullptr +#else #define PJ_DEFAULT_CTX 0 +#endif PJ_CONTEXT PROJ_DLL *proj_context_create (void); PJ_CONTEXT PROJ_DLL *proj_context_destroy (PJ_CONTEXT *ctx); diff --git a/src/proj_4D_api.cpp b/src/proj_4D_api.cpp index c2a37a49..da2ba28d 100644 --- a/src/proj_4D_api.cpp +++ b/src/proj_4D_api.cpp @@ -130,7 +130,7 @@ double proj_roundtrip (PJ *P, PJ_DIRECTION direction, int n, PJ_COORD *coord) { int i; PJ_COORD t, org; - if (0==P) + if (nullptr==P) return HUGE_VAL; if (n < 1) { @@ -169,7 +169,7 @@ available. See also pj_approx_2D_trans and pj_approx_3D_trans in pj_internal.c, which work similarly, but prefers the 2D resp. 3D interfaces if available. ***************************************************************************************/ - if (0==P) + if (nullptr==P) return coord; if (P->inverted) direction = opposite_direction(direction); @@ -274,17 +274,17 @@ size_t proj_trans_generic ( size_t i, nmin; double null_broadcast = 0; - if (0==P) + if (nullptr==P) return 0; if (P->inverted) direction = opposite_direction(direction); /* ignore lengths of null arrays */ - if (0==x) nx = 0; - if (0==y) ny = 0; - if (0==z) nz = 0; - if (0==t) nt = 0; + if (nullptr==x) nx = 0; + if (nullptr==y) ny = 0; + if (nullptr==z) nz = 0; + if (nullptr==t) nt = 0; /* and make the nullities point to some real world memory for broadcasting nulls */ if (0==nx) x = &null_broadcast; @@ -433,7 +433,7 @@ Returns 1 on success, 0 on failure PJ *Q; paralist *p; int do_cart = 0; - if (0==P) + if (nullptr==P) return 0; /* Don't recurse when calling proj_create (which calls us back) */ @@ -446,12 +446,12 @@ Returns 1 on success, 0 on failure /* Don't axisswap if data are already in "enu" order */ if (p && (0!=strcmp ("enu", p->param))) { char *def = static_cast<char*>(malloc (100+strlen(P->axis))); - if (0==def) + if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=axisswap axis=%s", P->axis); Q = proj_create (P->ctx, def); free (def); - if (0==Q) + if (nullptr==Q) return 0; P->axisswap = skip_prep_fin(Q); } @@ -461,12 +461,12 @@ Returns 1 on success, 0 on failure if (p && strlen (p->param) > strlen ("geoidgrids=")) { char *gridnames = p->param + strlen ("geoidgrids="); char *def = static_cast<char*>(malloc (100+strlen(gridnames))); - if (0==def) + if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=vgridshift grids=%s", gridnames); Q = proj_create (P->ctx, def); free (def); - if (0==Q) + if (nullptr==Q) return 0; P->vgridshift = skip_prep_fin(Q); } @@ -476,18 +476,18 @@ Returns 1 on success, 0 on failure if (p && strlen (p->param) > strlen ("nadgrids=")) { char *gridnames = p->param + strlen ("nadgrids="); char *def = static_cast<char*>(malloc (100+strlen(gridnames))); - if (0==def) + if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=hgridshift grids=%s", gridnames); Q = proj_create (P->ctx, def); free (def); - if (0==Q) + if (nullptr==Q) return 0; P->hgridshift = skip_prep_fin(Q); } /* We ignore helmert if we have grid shift */ - p = P->hgridshift ? 0 : pj_param_exists (P->params, "towgs84"); + p = P->hgridshift ? nullptr : pj_param_exists (P->params, "towgs84"); while (p) { char *def; char *s = p->param; @@ -508,12 +508,12 @@ Returns 1 on success, 0 on failure return 0; def = static_cast<char*>(malloc (100+n)); - if (0==def) + if (nullptr==def) return 0; sprintf (def, "break_cs2cs_recursion proj=helmert exact %s convention=position_vector", s); Q = proj_create (P->ctx, def); free(def); - if (0==Q) + if (nullptr==Q) return 0; pj_inherit_ellipsoid_def (P, Q); P->helmert = skip_prep_fin (Q); @@ -533,19 +533,19 @@ Returns 1 on success, 0 on failure /* TODO later: use C++ ostringstream with imbue(std::locale::classic()) */ /* to be locale unaware */ char* next_pos; - for (next_pos = def; (next_pos = strchr (next_pos, ',')) != NULL; next_pos++) { + for (next_pos = def; (next_pos = strchr (next_pos, ',')) != nullptr; next_pos++) { *next_pos = '.'; } } Q = proj_create (P->ctx, def); - if (0==Q) + if (nullptr==Q) return 0; P->cart = skip_prep_fin (Q); if (!P->is_geocent) { sprintf (def, "break_cs2cs_recursion proj=cart ellps=WGS84"); Q = proj_create (P->ctx, def); - if (0==Q) + if (nullptr==Q) return 0; P->cart_wgs84 = skip_prep_fin (Q); } @@ -573,15 +573,15 @@ PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) { int ret; int allow_init_epsg; - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx (); /* Make a copy that we can manipulate */ n = strlen (definition); args = (char *) malloc (n + 1); - if (0==args) { + if (nullptr==args) { proj_context_errno_set(ctx, ENOMEM); - return 0; + return nullptr; } strcpy (args, definition); @@ -589,7 +589,7 @@ PJ *proj_create (PJ_CONTEXT *ctx, const char *definition) { if (argc==0) { pj_dealloc (args); proj_context_errno_set(ctx, PJD_ERR_NO_ARGS); - return 0; + return nullptr; } argv = pj_trim_argv (argc, args); @@ -624,18 +624,18 @@ indicator, as in {"+proj=utm", "+zone=32"}, or leave it out, as in {"proj=utm", PJ *P; const char *c; - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx (); - if (0==argv) { + if (nullptr==argv) { proj_context_errno_set(ctx, PJD_ERR_NO_ARGS); - return 0; + return nullptr; } /* We assume that free format is used, and build a full proj_create compatible string */ c = pj_make_args (argc, argv); - if (0==c) { + if (nullptr==c) { proj_context_errno_set(ctx, ENOMEM); - return 0; + return nullptr; } P = proj_create (ctx, c); @@ -672,7 +672,7 @@ void proj_area_destroy(PJ_AREA* area) { /************************************************************************/ void proj_context_use_proj4_init_rules(PJ_CONTEXT *ctx, int enable) { - if( ctx == NULL ) { + if( ctx == nullptr ) { ctx = pj_get_default_ctx(); } ctx->use_proj4_init_rules = enable; @@ -697,7 +697,7 @@ static int EQUAL(const char* a, const char* b) { int proj_context_get_use_proj4_init_rules(PJ_CONTEXT *ctx, int from_legacy_code_path) { const char* val = getenv("PROJ_USE_PROJ4_INIT_RULES"); - if( ctx == NULL ) { + if( ctx == nullptr ) { ctx = pj_get_default_ctx(); } @@ -751,26 +751,26 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char PJ_OBJ_LIST* op_list; PJ_OBJ* op; const char* proj_string; - const char* const optionsProj4Mode[] = { "USE_PROJ4_INIT_RULES=YES", NULL }; + const char* const optionsProj4Mode[] = { "USE_PROJ4_INIT_RULES=YES", nullptr }; const char* const* optionsImportCRS = - proj_context_get_use_proj4_init_rules(ctx, FALSE) ? optionsProj4Mode : NULL; + proj_context_get_use_proj4_init_rules(ctx, FALSE) ? optionsProj4Mode : nullptr; src = proj_obj_create_from_user_input(ctx, source_crs, optionsImportCRS); if( !src ) { - return NULL; + return nullptr; } dst = proj_obj_create_from_user_input(ctx, target_crs, optionsImportCRS); if( !dst ) { proj_obj_destroy(src); - return NULL; + return nullptr; } - operation_ctx = proj_create_operation_factory_context(ctx, NULL); + operation_ctx = proj_create_operation_factory_context(ctx, nullptr); if( !operation_ctx ) { proj_obj_destroy(src); proj_obj_destroy(dst); - return NULL; + return nullptr; } if( area && area->bbox_set ) { @@ -793,24 +793,24 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char proj_obj_destroy(dst); if( !op_list ) { - return NULL; + return nullptr; } if( proj_obj_list_get_count(op_list) == 0 ) { proj_obj_list_destroy(op_list); - return NULL; + return nullptr; } op = proj_obj_list_get(ctx, op_list, 0); proj_obj_list_destroy(op_list); if( !op ) { - return NULL; + return nullptr; } - proj_string = proj_obj_as_proj_string(ctx, op, PJ_PROJ_5, NULL); + proj_string = proj_obj_as_proj_string(ctx, op, PJ_PROJ_5, nullptr); if( !proj_string) { proj_obj_destroy(op); - return NULL; + return nullptr; } if( proj_string[0] == '\0' ) { @@ -827,7 +827,7 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *source_crs, const char PJ *proj_destroy (PJ *P) { pj_free (P); - return 0; + return nullptr; } /*****************************************************************************/ @@ -844,7 +844,7 @@ int proj_context_errno (PJ_CONTEXT *ctx) { Read an error directly from a context, without going through a PJ belonging to that context. ******************************************************************************/ - if (0==ctx) + if (nullptr==ctx) ctx = pj_get_default_ctx(); return pj_ctx_get_errno (ctx); } @@ -925,15 +925,15 @@ PJ_CONTEXT *proj_context_create (void) { PJ_CONTEXT *proj_context_destroy (PJ_CONTEXT *ctx) { - if (0==ctx) - return 0; + if (nullptr==ctx) + return nullptr; /* Trying to free the default context is a no-op (since it is statically allocated) */ if (pj_get_default_ctx ()==ctx) - return 0; + return nullptr; pj_ctx_free (ctx); - return 0; + return nullptr; } @@ -958,26 +958,26 @@ static char *path_append (char *buf, const char *app, size_t *buf_size) { #endif /* Nothing to do? */ - if (0 == app) + if (nullptr == app) return buf; applen = strlen (app); if (0 == applen) return buf; /* Start checking whether buf is long enough */ - if (0 != buf) + if (nullptr != buf) buflen = strlen (buf); len = buflen+applen+strlen (delim) + 1; /* "pj_realloc", so to speak */ if (*buf_size < len) { p = static_cast<char*>(pj_calloc (2 * len, sizeof (char))); - if (0==p) { + if (nullptr==p) { pj_dealloc (buf); - return 0; + return nullptr; } *buf_size = 2 * len; - if (buf != 0) + if (buf != nullptr) strcpy (p, buf); pj_dealloc (buf); buf = p; @@ -992,7 +992,7 @@ static char *path_append (char *buf, const char *app, size_t *buf_size) { static const char *empty = {""}; static char version[64] = {""}; -static PJ_INFO info = {0, 0, 0, 0, 0, 0, 0, 0}; +static PJ_INFO info = {0, 0, 0, nullptr, nullptr, nullptr, nullptr, 0}; static volatile int info_initialized = 0; /*****************************************************************************/ @@ -1006,7 +1006,7 @@ PJ_INFO proj_info (void) { size_t i, n; size_t buf_size = 0; - char *buf = 0; + char *buf = nullptr; pj_acquire_lock (); @@ -1065,7 +1065,7 @@ PJ_PROJ_INFO proj_pj_info(PJ *P) { /* proj_create_crs_to_crs in a future version that leverages the EPSG database. */ pjinfo.accuracy = -1.0; - if (0==P) + if (nullptr==P) return pjinfo; /* projection id */ @@ -1080,7 +1080,7 @@ PJ_PROJ_INFO proj_pj_info(PJ *P) { def = P->def_full; else def = pj_get_def(P, 0); /* pj_get_def takes a non-const PJ pointer */ - if (0==def) + if (nullptr==def) pjinfo.definition = empty; else pjinfo.definition = pj_shrink (def); @@ -1107,7 +1107,7 @@ PJ_GRID_INFO proj_grid_info(const char *gridname) { memset(&grinfo, 0, sizeof(PJ_GRID_INFO)); /* in case the grid wasn't found */ - if (gridinfo->filename == NULL) { + if (gridinfo->filename == nullptr) { pj_gridinfo_free(ctx, gridinfo); strcpy(grinfo.format, "missing"); return grinfo; @@ -1258,7 +1258,7 @@ PJ_FACTORS proj_factors(PJ *P, PJ_COORD lp) { PJ_FACTORS factors = {0,0,0, 0,0,0, 0,0, 0,0,0,0}; struct FACTORS f; - if (0==P) + if (nullptr==P) return factors; if (pj_factors(lp.lp, P, 0.0, &f)) diff --git a/src/proj_etmerc.cpp b/src/proj_etmerc.cpp index b521c329..05f86f37 100644 --- a/src/proj_etmerc.cpp +++ b/src/proj_etmerc.cpp @@ -309,7 +309,7 @@ static PJ *setup(PJ *P) { /* general initialization */ PJ *PROJECTION(etmerc) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; return setup (P); @@ -323,7 +323,7 @@ PJ *PROJECTION(etmerc) { PJ *PROJECTION(utm) { long zone; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor (P, ENOMEM); P->opaque = Q; diff --git a/src/proj_mdist.cpp b/src/proj_mdist.cpp index c645d117..e3f0f5c6 100644 --- a/src/proj_mdist.cpp +++ b/src/proj_mdist.cpp @@ -73,8 +73,8 @@ proj_mdist_ini(double es) { El = Es; } if ((b = (struct MDIST *)malloc(sizeof(struct MDIST)+ - (i*sizeof(double)))) == NULL) - return(NULL); + (i*sizeof(double)))) == nullptr) + return(nullptr); b->nb = i - 1; b->es = es; b->E = Es; diff --git a/src/proj_rouss.cpp b/src/proj_rouss.cpp index f4fa084f..3b4428bc 100644 --- a/src/proj_rouss.cpp +++ b/src/proj_rouss.cpp @@ -86,10 +86,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ static PJ *destructor (PJ *P, int errlev) { - if (0==P) - return 0; + if (nullptr==P) + return nullptr; - if (0==P->opaque) + if (nullptr==P->opaque) return pj_default_destructor (P, errlev); if (static_cast<struct pj_opaque*>(P->opaque)->en) @@ -103,7 +103,7 @@ PJ *PROJECTION(rouss) { double N0, es2, t, t2, R_R0_2, R_R0_4; struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque))); - if (0==Q) + if (nullptr==Q) return pj_default_destructor(P, ENOMEM); P->opaque = Q; diff --git a/src/proj_strtod.cpp b/src/proj_strtod.cpp index 05d448ec..b8edc6a3 100644 --- a/src/proj_strtod.cpp +++ b/src/proj_strtod.cpp @@ -106,7 +106,7 @@ double proj_strtod(const char *str, char **endptr) { int num_digits_after_comma = 0; int num_prefixed_zeros = 0; - if (0==str) { + if (nullptr==str) { errno = EFAULT; if (endptr) *endptr = p; @@ -125,7 +125,7 @@ double proj_strtod(const char *str, char **endptr) { } /* non-numeric? */ - if (0==strchr("0123456789+-._", *p)) { + if (nullptr==strchr("0123456789+-._", *p)) { if (endptr) *endptr = (char *) str; return 0; @@ -150,7 +150,7 @@ double proj_strtod(const char *str, char **endptr) { } /* stray sign, as in "+/-"? */ - if (0!=sign && (0==strchr ("0123456789._", *p) || 0==*p)) { + if (0!=sign && (nullptr==strchr ("0123456789._", *p) || 0==*p)) { if (endptr) *endptr = (char *) str; return 0; @@ -161,7 +161,7 @@ double proj_strtod(const char *str, char **endptr) { p++; /* zero? */ - if ((0==*p) || 0==strchr ("0123456789eE.", *p) || isspace(*p)) { + if ((0==*p) || nullptr==strchr ("0123456789eE.", *p) || isspace(*p)) { if (endptr) *endptr = p; return sign==-1? -0: 0; @@ -202,7 +202,7 @@ double proj_strtod(const char *str, char **endptr) { } /* if the next character is nonnumeric, we have reached the end */ - if (0==*p || 0==strchr ("_0123456789eE+-", *p)) { + if (0==*p || nullptr==strchr ("_0123456789eE+-", *p)) { if (endptr) *endptr = p; if (sign==-1) @@ -249,7 +249,7 @@ double proj_strtod(const char *str, char **endptr) { p++; /* Just a stray "e", as in 100elephants? */ - if (0==*p || 0==strchr ("0123456789+-_", *p)) { + if (0==*p || nullptr==strchr ("0123456789+-_", *p)) { p--; break; } diff --git a/src/projects.h b/src/projects.h index ac1a2152..099684d3 100644 --- a/src/projects.h +++ b/src/projects.h @@ -627,8 +627,8 @@ C_NAMESPACE PJ *pj_##name (PJ *P) { \ if (P) \ return pj_projection_specific_setup_##name (P); \ P = (PJ*) pj_calloc (1, sizeof(PJ)); \ - if (0==P) \ - return 0; \ + if (nullptr==P) \ + return nullptr; \ P->destructor = pj_default_destructor; \ P->descr = des_##name; \ P->need_ellps = NEED_ELLPS; \ diff --git a/src/test228.cpp b/src/test228.cpp index 83d29f8f..fcacd7c9 100644 --- a/src/test228.cpp +++ b/src/test228.cpp @@ -49,7 +49,7 @@ static void* thread_main(void* unused) x = -5.2*DEG_TO_RAD; y = 50*DEG_TO_RAD; proj_ret = pj_transform(p_WGS84_proj, - p_OSGB36_proj, 1, 1, &x, &y, NULL ); + p_OSGB36_proj, 1, 1, &x, &y, nullptr ); x *= RAD_TO_DEG; y *= RAD_TO_DEG; /*printf("%.18f %.18f\n", x, y); */ @@ -60,7 +60,7 @@ static void* thread_main(void* unused) pj_free (p_OSGB36_proj); pj_free (p_WGS84_proj); - return NULL; + return nullptr; } int main() @@ -73,8 +73,8 @@ int main() pthread_attr_init(&attr1); pthread_attr_init(&attr2); - pthread_create(&tid1, &attr1, thread_main, NULL); - pthread_create(&tid2, &attr2, thread_main, NULL); + pthread_create(&tid1, &attr1, thread_main, nullptr); + pthread_create(&tid2, &attr2, thread_main, nullptr); while(started != 2); run = 1; for(i=0;i<2;i++) diff --git a/src/vector1.cpp b/src/vector1.cpp index 22e1f5d0..869dd76a 100644 --- a/src/vector1.cpp +++ b/src/vector1.cpp @@ -15,14 +15,14 @@ freev2(void **v, int nrows) { vector2(int nrows, int ncols, int size) { void **s; - if ((s = (void **)pj_malloc(sizeof(void *) * nrows)) != NULL) { + if ((s = (void **)pj_malloc(sizeof(void *) * nrows)) != nullptr) { int rsize, i; rsize = size * ncols; for (i = 0; i < nrows; ++i) if (!(s[i] = pj_malloc(rsize))) { freev2(s, i); - return (void **)0; + return (void **)nullptr; } } return s; |
