/
| 135 | |
| 136 | /*****************************************************************************/ |
| 137 | PJ *pj_default_destructor(PJ *P, int errlev) { /* Destructor */ |
| 138 | /***************************************************************************** |
| 139 | Does memory deallocation for "plain" PJ objects, i.e. that vast majority |
| 140 | of PJs where the opaque object does not contain any additionally |
| 141 | allocated memory below the P->opaque level. |
| 142 | ******************************************************************************/ |
| 143 | |
| 144 | /* Even if P==0, we set the errlev on pj_error and the default context */ |
| 145 | /* Note that both, in the multithreaded case, may then contain undefined */ |
| 146 | /* values. This is expected behavior. For MT have one ctx per thread */ |
| 147 | if (0 != errlev) |
| 148 | proj_context_errno_set(pj_get_ctx(P), errlev); |
| 149 | |
| 150 | if (nullptr == P) |
| 151 | return nullptr; |
| 152 | |
| 153 | free(P->def_size); |
| 154 | free(P->def_shape); |
| 155 | free(P->def_spherification); |
| 156 | free(P->def_ellps); |
| 157 | |
| 158 | delete static_cast<ListOfHGrids *>(P->hgrids_legacy); |
| 159 | delete static_cast<ListOfVGrids *>(P->vgrids_legacy); |
| 160 | |
| 161 | /* We used to call free( P->catalog ), but this will leak */ |
| 162 | /* memory. The safe way to clear catalog and grid is to call */ |
| 163 | /* pj_gc_unloadall(pj_get_default_ctx()); and freeate_grids(); */ |
| 164 | /* TODO: we should probably have a public pj_cleanup() method to do all */ |
| 165 | /* that */ |
| 166 | |
| 167 | /* free the interface to Charles Karney's geodesic library */ |
| 168 | free(P->geod); |
| 169 | |
| 170 | /* free parameter list elements */ |
| 171 | free_params(pj_get_ctx(P), P->params, errlev); |
| 172 | free(P->def_full); |
| 173 | |
| 174 | /* free the cs2cs emulation elements */ |
| 175 | proj_destroy(P->axisswap); |
| 176 | proj_destroy(P->helmert); |
| 177 | proj_destroy(P->cart); |
| 178 | proj_destroy(P->cart_wgs84); |
| 179 | proj_destroy(P->hgridshift); |
| 180 | proj_destroy(P->vgridshift); |
| 181 | |
| 182 | proj_destroy(P->cached_op_for_proj_factors); |
| 183 | |
| 184 | free(static_cast<struct pj_opaque *>(P->opaque)); |
| 185 | delete P; |
| 186 | return nullptr; |
| 187 | } |
| 188 | |
| 189 | /*****************************************************************************/ |
| 190 | void proj_cleanup() { |
no test coverage detected