diff options
| author | Thomas Knudsen <thokn@sdfe.dk> | 2017-09-27 13:56:34 +0200 |
|---|---|---|
| committer | Thomas Knudsen <thokn@sdfe.dk> | 2017-10-06 11:39:27 +0200 |
| commit | 664577ced6a8e4074b1f53af82b5ae5d1d189eac (patch) | |
| tree | a29d4a6c0842bb87df63fc913502c3b6c5b097a5 /src/PJ_lsat.c | |
| parent | 0495fdca92fc620d44572ce1e4e871f57f968198 (diff) | |
| download | PROJ-664577ced6a8e4074b1f53af82b5ae5d1d189eac.tar.gz PROJ-664577ced6a8e4074b1f53af82b5ae5d1d189eac.zip | |
Enable default destructor for all PJ objects.
In most cases memory deallocation is completely removed from the
code since it can be handled by the default destructor. In a few
special cases a local destructor overrides the default destructor
and makes sure that locally allocated memored is cleaned up correctly.
Move all deallocation from pj_free to pj_default_destructor
Rename pj_latlong.c to fit with the conventional format PJ_latlong.c - freeup was missed here due to wrong naming
Clean up pj_init to avoid double deallocation; Also resolve #576 by adding z_0 and t_0 options in pj_init, while cleaning
Add a prototype for dealloc_params
Added missing errno.h include in pj_ctx.c
Temporarily removing ob_tran from testvarious, to be sure that is where the trouble is
Make PJ_ob_tran.c use proper initialization for the chained projection
proj=ob_tran: make it clear, that we disallow ellipsoidal projections, and, for improved backwards compatibility, turns off default settings, which could inject unwanted ellipsoid definitions
... then also remove the ellipsoid definition from the testvarious test case - which is probably buggy anyway
Work around cs2cs spherical init bug in testvarious; Forbid defs for ob_tran in pj_init
Diffstat (limited to 'src/PJ_lsat.c')
| -rw-r--r-- | src/PJ_lsat.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/PJ_lsat.c b/src/PJ_lsat.c index 15009d61..1b3778d6 100644 --- a/src/PJ_lsat.c +++ b/src/PJ_lsat.c @@ -1,5 +1,6 @@ /* based upon Snyder and Linck, USGS-NMD */ #define PJ_LIB__ +#include <errno.h> #include <proj.h> #include "projects.h" @@ -148,40 +149,22 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ } -static void *freeup_new (PJ *P) { /* Destructor */ - if (0==P) - return 0; - if (0==P->opaque) - return pj_dealloc (P); - - pj_dealloc (P->opaque); - return pj_dealloc(P); -} - -static void freeup (PJ *P) { - freeup_new (P); - return; -} - - PJ *PROJECTION(lsat) { int land, path; double lam, alf, esc, ess; struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque)); if (0==Q) - return freeup_new (P); + return pj_default_destructor(P, ENOMEM); P->opaque = Q; land = pj_param(P->ctx, P->params, "ilsat").i; - if (land <= 0 || land > 5) { - proj_errno_set(P, PJD_ERR_LSAT_NOT_IN_RANGE); - return freeup_new(P); - } + if (land <= 0 || land > 5) + return pj_default_destructor(P, PJD_ERR_LSAT_NOT_IN_RANGE); + path = pj_param(P->ctx, P->params, "ipath").i; - if (path <= 0 || path > (land <= 3 ? 251 : 233)) { - proj_errno_set(P, PJD_ERR_PATH_NOT_IN_RANGE); - return freeup_new(P); - } + if (path <= 0 || path > (land <= 3 ? 251 : 233)) + pj_default_destructor(P, PJD_ERR_PATH_NOT_IN_RANGE); + if (land <= 3) { P->lam0 = DEG_TO_RAD * 128.87 - M_TWOPI / 251. * path; Q->p22 = 103.2669323; |
