aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-08-26 23:21:12 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-08-26 23:21:12 +0200
commit96ac0f210b6dd3fdb499115d83bc13ff7739cd60 (patch)
tree976815754bd15dabb80311f5f6da4a9da0cf88dc
parent10a30bb539be1afb25952b19af8bbe72e1b13b56 (diff)
downloadPROJ-96ac0f210b6dd3fdb499115d83bc13ff7739cd60.tar.gz
PROJ-96ac0f210b6dd3fdb499115d83bc13ff7739cd60.zip
Add a proj_cleanup() function to free global resources, typically at process termination
-rw-r--r--docs/source/development/reference/functions.rst13
-rw-r--r--scripts/reference_exported_symbols.txt1
-rw-r--r--src/apps/cs2cs.cpp2
-rw-r--r--src/malloc.cpp7
-rw-r--r--src/proj.h2
5 files changed, 24 insertions, 1 deletions
diff --git a/docs/source/development/reference/functions.rst b/docs/source/development/reference/functions.rst
index e5f48439..c010fd13 100644
--- a/docs/source/development/reference/functions.rst
+++ b/docs/source/development/reference/functions.rst
@@ -696,6 +696,19 @@ Various
:type `direction`: PJ_DIRECTION
:returns: :c:type:`int` 1 if output units is expected in radians, otherwise 0
+
+Cleanup
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+.. c:function:: void proj_cleanup()
+
+ .. versionadded:: 6.2.0
+
+ This function frees global resources (grids, cache of +init files). It
+ should be called typically before process termination, and *after* having
+ freed PJ and PJ_CONTEXT objects.
+
+
C API for ISO-19111 functionality
+++++++++++++++++++++++++++++++++
diff --git a/scripts/reference_exported_symbols.txt b/scripts/reference_exported_symbols.txt
index 6df84099..71de2d0e 100644
--- a/scripts/reference_exported_symbols.txt
+++ b/scripts/reference_exported_symbols.txt
@@ -773,6 +773,7 @@ proj_as_projjson
proj_as_proj_string
proj_assign_context
proj_as_wkt
+proj_cleanup
proj_clone
proj_concatoperation_get_step
proj_concatoperation_get_step_count
diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp
index 20e5e73c..3099c3e8 100644
--- a/src/apps/cs2cs.cpp
+++ b/src/apps/cs2cs.cpp
@@ -645,7 +645,7 @@ int main(int argc, char **argv) {
proj_destroy(transformation);
- pj_deallocate_grids();
+ proj_cleanup();
exit(0); /* normal completion */
}
diff --git a/src/malloc.cpp b/src/malloc.cpp
index 817f8f20..393437e3 100644
--- a/src/malloc.cpp
+++ b/src/malloc.cpp
@@ -255,3 +255,10 @@ PJ *pj_default_destructor (PJ *P, int errlev) { /* Destructor */
delete P;
return nullptr;
}
+
+/*****************************************************************************/
+void proj_cleanup() {
+/*****************************************************************************/
+ pj_clear_initcache();
+ pj_deallocate_grids();
+}
diff --git a/src/proj.h b/src/proj.h
index 9cf83df7..e5e9df4c 100644
--- a/src/proj.h
+++ b/src/proj.h
@@ -458,6 +458,8 @@ double PROJ_DLL proj_todeg (double angle_in_radians);
double PROJ_DLL proj_dmstor(const char *is, char **rs);
char PROJ_DLL * proj_rtodms(char *s, double r, int pos, int neg);
+void PROJ_DLL proj_cleanup(void);
+
/*! @endcond */
/* ------------------------------------------------------------------------- */