From 96ac0f210b6dd3fdb499115d83bc13ff7739cd60 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 26 Aug 2019 23:21:12 +0200 Subject: Add a proj_cleanup() function to free global resources, typically at process termination --- src/apps/cs2cs.cpp | 2 +- src/malloc.cpp | 7 +++++++ src/proj.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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 */ /* ------------------------------------------------------------------------- */ -- cgit v1.2.3