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_ctx.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_ctx.c')
| -rw-r--r-- | src/pj_ctx.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pj_ctx.c b/src/pj_ctx.c index 32a3d690..7ba85e78 100644 --- a/src/pj_ctx.c +++ b/src/pj_ctx.c @@ -27,6 +27,7 @@ #include <projects.h> #include <string.h> +#include <errno.h> static projCtx_t default_context; static volatile int default_context_initialized = 0; @@ -40,6 +41,8 @@ projCtx pj_get_ctx( projPJ pj ) { if (0==pj) return pj_get_default_ctx (); + if (0==pj->ctx) + return pj_get_default_ctx (); return pj->ctx; } @@ -130,14 +133,20 @@ int pj_ctx_get_errno( projCtx ctx ) /* pj_ctx_set_errno() */ /* */ /* Also sets the global errno. */ +/* Since pj_errno makes sense in single threaded cases only, */ +/* we set it only when called on the default context. */ /************************************************************************/ void pj_ctx_set_errno( projCtx ctx, int new_errno ) { ctx->last_errno = new_errno; - if( new_errno != 0 ) - pj_errno = new_errno; + if (ctx!=pj_get_default_ctx()) + return; + if( new_errno == 0 ) + return; + pj_errno = new_errno; + errno = new_errno; } /************************************************************************/ |
