diff options
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; } |
