Skip to content

Commit 8bf57e5

Browse files
committed
proj_cleanup(): make it release (static) memory allocated by proj_info()
Fixes #4754
1 parent 2f67ec9 commit 8bf57e5

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/info.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ PJ_INFO proj_info(void) {
135135
return info;
136136
}
137137

138+
/*****************************************************************************/
139+
void pj_clear_proj_info()
140+
/*****************************************************************************/
141+
/* Release memory associated to "info" singleton
142+
/*****************************************************************************/
143+
{
144+
pj_acquire_lock();
145+
free(const_cast<char *>(info.searchpath));
146+
info.searchpath = nullptr;
147+
pj_release_lock();
148+
}
149+
138150
/*****************************************************************************/
139151
PJ_PROJ_INFO proj_pj_info(PJ *P) {
140152
/******************************************************************************

src/malloc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,5 @@ void proj_cleanup() {
204204
pj_clear_vgridshift_knowngrids_cache();
205205
pj_clear_gridshift_knowngrids_cache();
206206
pj_clear_sqlite_cache();
207+
pj_clear_proj_info();
207208
}

src/proj_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,8 @@ int pj_get_suggested_operation(PJ_CONTEXT *ctx,
10041004
const PJ_UNITS *pj_list_linear_units();
10051005
const PJ_UNITS *pj_list_angular_units();
10061006

1007+
void pj_clear_proj_info();
1008+
10071009
void pj_clear_hgridshift_knowngrids_cache();
10081010
void pj_clear_vgridshift_knowngrids_cache();
10091011
void pj_clear_gridshift_knowngrids_cache();

0 commit comments

Comments
 (0)