diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2018-12-31 11:37:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-31 11:37:51 +0100 |
| commit | 32f3ef47e55c38b0eabb6d781fee3944d3239414 (patch) | |
| tree | ba2850500ee732559bada055dbab281ceff49a22 /src/malloc.cpp | |
| parent | 5c41d3a1078895ed096b416db15c91108bccad87 (diff) | |
| parent | 0e0e0e475414ddeb75e0e140d8a3381a431036d9 (diff) | |
| download | PROJ-32f3ef47e55c38b0eabb6d781fee3944d3239414.tar.gz PROJ-32f3ef47e55c38b0eabb6d781fee3944d3239414.zip | |
Merge pull request #1208 from rouault/merge_PJ_and_PJ_OBJ
Unify PJ_OBJ and PJ structures
Diffstat (limited to 'src/malloc.cpp')
| -rw-r--r-- | src/malloc.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/malloc.cpp b/src/malloc.cpp index c8681570..6bd4639e 100644 --- a/src/malloc.cpp +++ b/src/malloc.cpp @@ -44,8 +44,10 @@ #include <stdlib.h> #include <string.h> +#include <new> + #include "proj.h" -#include "projects.h" +#include "proj_internal.h" /**********************************************************************/ void *pj_malloc(size_t size) { @@ -178,7 +180,7 @@ void *pj_dealloc_params (PJ_CONTEXT *ctx, paralist *start, int errlev) { /************************************************************************/ void pj_free(PJ *P) { - if (nullptr==P) + if (nullptr==P || !P->destructor) return; /* free projection parameters - all the hard work is done by */ /* pj_default_destructor, which is supposed */ @@ -188,7 +190,16 @@ void pj_free(PJ *P) { P->destructor (P, proj_errno(P)); } +/*****************************************************************************/ +// cppcheck-suppress uninitMemberVar +PJconsts::PJconsts(): destructor(pj_default_destructor) {} +/*****************************************************************************/ +/*****************************************************************************/ +PJ *pj_new() { +/*****************************************************************************/ + return new(std::nothrow) PJ(); +} /*****************************************************************************/ @@ -235,6 +246,6 @@ PJ *pj_default_destructor (PJ *P, int errlev) { /* Destructor */ pj_free (P->vgridshift); pj_dealloc (static_cast<struct pj_opaque*>(P->opaque)); - pj_dealloc(P); + delete P; return nullptr; } |
