aboutsummaryrefslogtreecommitdiff
path: root/src/pj_malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pj_malloc.c')
-rw-r--r--src/pj_malloc.c38
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);