Skip to content

Commit 7570871

Browse files
authored
Merge pull request #4759 from OSGeo/backport-4755-to-9.8
[Backport 9.8] proj_cleanup(): make it release (static) memory allocated by proj_info()
2 parents 8a16c0c + 7fd4139 commit 7570871

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/info.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,19 @@ 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+
if (info.searchpath != empty)
146+
free(const_cast<char *>(info.searchpath));
147+
info.searchpath = nullptr;
148+
pj_release_lock();
149+
}
150+
138151
/*****************************************************************************/
139152
PJ_PROJ_INFO proj_pj_info(PJ *P) {
140153
/******************************************************************************

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
@@ -1003,6 +1003,8 @@ int pj_get_suggested_operation(PJ_CONTEXT *ctx,
10031003
const PJ_UNITS *pj_list_linear_units();
10041004
const PJ_UNITS *pj_list_angular_units();
10051005

1006+
void pj_clear_proj_info();
1007+
10061008
void pj_clear_hgridshift_knowngrids_cache();
10071009
void pj_clear_vgridshift_knowngrids_cache();
10081010
void pj_clear_gridshift_knowngrids_cache();

0 commit comments

Comments
 (0)