diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2018-02-19 22:39:17 +0100 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2018-02-19 22:39:17 +0100 |
| commit | 43d811d20598abde95a8d177123e9f26fe5229ab (patch) | |
| tree | c66684d7975798109a072b52bce5e7c5f9bd5182 /src/pj_malloc.c | |
| parent | a9e08ad008b1ff16d6139aab5e813058c922eef8 (diff) | |
| parent | efa636e0d9e0cef5a5fff1b7ed76d0368d20121b (diff) | |
| download | PROJ-43d811d20598abde95a8d177123e9f26fe5229ab.tar.gz PROJ-43d811d20598abde95a8d177123e9f26fe5229ab.zip | |
Merge remote-tracking branch 'osgeo/master' into docs-release-4.10.0
Diffstat (limited to 'src/pj_malloc.c')
| -rw-r--r-- | src/pj_malloc.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/pj_malloc.c b/src/pj_malloc.c index c9275074..127e76ee 100644 --- a/src/pj_malloc.c +++ b/src/pj_malloc.c @@ -40,6 +40,7 @@ ** projection system memory allocation/deallocation call with custom ** application procedures. */ +#include <proj.h> #include "projects.h" #include <errno.h> @@ -143,7 +144,7 @@ char *pj_strdup(const char *str) /*****************************************************************************/ -void *pj_dealloc_params (projCtx ctx, paralist *start, int errlev) { +void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) { /***************************************************************************** Companion to pj_default_destructor (below). Deallocates a linked list of "+proj=xxx" initialization parameters. @@ -161,6 +162,32 @@ void *pj_dealloc_params (projCtx ctx, paralist *start, int errlev) { } + + +/************************************************************************/ +/* pj_free() */ +/* */ +/* This is the application callable entry point for destroying */ +/* a projection definition. It does work generic to all */ +/* projection types, and then calls the projection specific */ +/* free function, P->destructor(), to do local work. */ +/* In most cases P->destructor()==pj_default_destructor. */ +/************************************************************************/ + +void pj_free(PJ *P) { + if (0==P) + return; + /* free projection parameters - all the hard work is done by */ + /* pj_default_destructor, which is supposed */ + /* to be called as the last step of the local destructor */ + /* pointed to by P->destructor. In most cases, */ + /* pj_default_destructor actually *is* what is pointed to */ + P->destructor (P, proj_errno(P)); +} + + + + /*****************************************************************************/ void *pj_default_destructor (PJ *P, int errlev) { /* Destructor */ /***************************************************************************** @@ -194,6 +221,15 @@ void *pj_default_destructor (PJ *P, int errlev) { /* Destructor */ /* free parameter list elements */ pj_dealloc_params (pj_get_ctx(P), P->params, errlev); + pj_dealloc (P->def_full); + + /* free the cs2cs emulation elements */ + pj_free (P->axisswap); + pj_free (P->helmert); + pj_free (P->cart); + pj_free (P->cart_wgs84); + pj_free (P->hgridshift); + pj_free (P->vgridshift); pj_dealloc (P->opaque); return pj_dealloc(P); |
