aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2020-11-18 09:57:42 +0100
committerKristian Evers <kristianevers@gmail.com>2020-11-20 16:40:40 +0100
commit43efca4ab87fb37a0931edcb6be11c0bd3784098 (patch)
treeb334bdb4d6898b740fbb4f300e6753a3d0878aff
parentddb3b8da0756acbb8713aeb452de209eb350e996 (diff)
downloadPROJ-43efca4ab87fb37a0931edcb6be11c0bd3784098.tar.gz
PROJ-43efca4ab87fb37a0931edcb6be11c0bd3784098.zip
Remove pj_free() and move it's functional parts to proj_destroy()
-rw-r--r--src/4D_api.cpp6
-rw-r--r--src/apps/cct.cpp2
-rw-r--r--src/apps/proj.cpp2
-rw-r--r--src/init.cpp4
-rw-r--r--src/malloc.cpp19
-rw-r--r--src/proj_internal.h1
-rw-r--r--src/projections/goode.cpp4
-rw-r--r--test/unit/gie_self_tests.cpp2
8 files changed, 18 insertions, 22 deletions
diff --git a/src/4D_api.cpp b/src/4D_api.cpp
index 70b04bf1..78e9bdc3 100644
--- a/src/4D_api.cpp
+++ b/src/4D_api.cpp
@@ -1353,10 +1353,6 @@ PJ *proj_create_crs_to_crs_from_pj (PJ_CONTEXT *ctx, const PJ *source_crs, cons
return P;
}
-PJ *proj_destroy (PJ *P) {
- pj_free (P);
- return nullptr;
-}
/*****************************************************************************/
int proj_errno (const PJ *P) {
@@ -1636,7 +1632,7 @@ PJ_PROJ_INFO proj_pj_info(PJ *P) {
pjinfo.definition = empty;
else
pjinfo.definition = pj_shrink (def);
- /* Make pj_free clean this up eventually */
+ /* Make proj_destroy clean this up eventually */
P->def_full = def;
pjinfo.has_inverse = pj_has_inverse(P);
diff --git a/src/apps/cct.cpp b/src/apps/cct.cpp
index fa75267a..e63a5fc2 100644
--- a/src/apps/cct.cpp
+++ b/src/apps/cct.cpp
@@ -387,7 +387,7 @@ int main(int argc, char **argv) {
buf = static_cast<char*>(calloc (1, 10000));
if (nullptr==buf) {
print (PJ_LOG_ERROR, "%s: Out of memory", o->progname);
- pj_free (P);
+ proj_destroy (P);
free (o);
if (stdout != fout)
fclose (fout);
diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp
index c9bd8950..8bfd99a3 100644
--- a/src/apps/proj.cpp
+++ b/src/apps/proj.cpp
@@ -562,7 +562,7 @@ int main(int argc, char **argv) {
}
if( Proj )
- pj_free(Proj);
+ proj_destroy(Proj);
exit(0); /* normal completion */
}
diff --git a/src/init.cpp b/src/init.cpp
index 2d679618..95bb404f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1,7 +1,7 @@
/******************************************************************************
* Project: PROJ.4
* Purpose: Initialize projection object from string definition. Includes
- * pj_init(), pj_init_plus() and pj_free() function.
+ * pj_init(), and pj_init_plus() function.
* Author: Gerald Evenden, Frank Warmerdam <warmerdam@pobox.com>
*
******************************************************************************
@@ -829,7 +829,7 @@ pj_init_ctx_with_allow_init_epsg(PJ_CONTEXT *ctx, int argc, char **argv, int all
err = proj_errno_reset (PIN);
PIN = proj(PIN);
if (proj_errno (PIN)) {
- pj_free(PIN);
+ proj_destroy(PIN);
return nullptr;
}
proj_errno_restore (PIN, err);
diff --git a/src/malloc.cpp b/src/malloc.cpp
index b1bcea1d..590dd27f 100644
--- a/src/malloc.cpp
+++ b/src/malloc.cpp
@@ -174,7 +174,7 @@ void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) {
/************************************************************************/
-/* pj_free() */
+/* proj_destroy() */
/* */
/* This is the application callable entry point for destroying */
/* a projection definition. It does work generic to all */
@@ -183,15 +183,16 @@ void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) {
/* In most cases P->destructor()==pj_default_destructor. */
/************************************************************************/
-void pj_free(PJ *P) {
+PJ *proj_destroy(PJ *P) {
if (nullptr==P || !P->destructor)
- return;
+ return nullptr;
/* free projection parameters - all the hard work is done by */
/* pj_default_destructor, which is supposed */
/* to be called as the last step of the local destructor */
/* pointed to by P->destructor. In most cases, */
/* pj_default_destructor actually *is* what is pointed to */
P->destructor (P, proj_errno(P));
+ return nullptr;
}
/*****************************************************************************/
@@ -246,12 +247,12 @@ PJ *pj_default_destructor (PJ *P, int errlev) { /* Destructor */
pj_dealloc (P->def_full);
/* free the cs2cs emulation elements */
- pj_free (P->axisswap);
- pj_free (P->helmert);
- pj_free (P->cart);
- pj_free (P->cart_wgs84);
- pj_free (P->hgridshift);
- pj_free (P->vgridshift);
+ proj_destroy (P->axisswap);
+ proj_destroy (P->helmert);
+ proj_destroy (P->cart);
+ proj_destroy (P->cart_wgs84);
+ proj_destroy (P->hgridshift);
+ proj_destroy (P->vgridshift);
pj_dealloc (static_cast<struct pj_opaque*>(P->opaque));
delete P;
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 24c9b653..d57e87a2 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -946,7 +946,6 @@ PJ_LPZ PROJ_DLL pj_inv3d(PJ_XYZ, PJ *);
void PROJ_DLL pj_clear_initcache(void);
void PROJ_DLL pj_pr_list(PJ *);
-void PROJ_DLL pj_free(PJ *);
PJ PROJ_DLL *pj_init(int, char **);
PJ PROJ_DLL *pj_init_plus(const char *);
PJ PROJ_DLL *pj_init_ctx( PJ_CONTEXT *, int, char ** );
diff --git a/src/projections/goode.cpp b/src/projections/goode.cpp
index fdace387..9a6fb86c 100644
--- a/src/projections/goode.cpp
+++ b/src/projections/goode.cpp
@@ -54,8 +54,8 @@ static PJ *destructor (PJ *P, int errlev) { /* Destructor */
return nullptr;
if (nullptr==P->opaque)
return pj_default_destructor (P, errlev);
- pj_free (static_cast<struct pj_opaque*>(P->opaque)->sinu);
- pj_free (static_cast<struct pj_opaque*>(P->opaque)->moll);
+ proj_destroy (static_cast<struct pj_opaque*>(P->opaque)->sinu);
+ proj_destroy (static_cast<struct pj_opaque*>(P->opaque)->moll);
return pj_default_destructor (P, errlev);
}
diff --git a/test/unit/gie_self_tests.cpp b/test/unit/gie_self_tests.cpp
index 6f1b3c32..f9252137 100644
--- a/test/unit/gie_self_tests.cpp
+++ b/test/unit/gie_self_tests.cpp
@@ -548,7 +548,7 @@ static void test_time(const char *args, double tol, double t_in, double t_exp) {
out = proj_trans(P, PJ_INV, out);
EXPECT_NEAR(out.xyzt.t, t_in, tol);
- pj_free(P);
+ proj_destroy(P);
proj_log_level(NULL, PJ_LOG_NONE);
}