diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-26 11:20:31 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-30 17:37:56 +0100 |
| commit | e1edf114105b0f528ef662f79297603617297a6b (patch) | |
| tree | 66bc44fef2dea2dcb8e474e999787c9158ec1b25 /src/malloc.cpp | |
| parent | 5c41d3a1078895ed096b416db15c91108bccad87 (diff) | |
| download | PROJ-e1edf114105b0f528ef662f79297603617297a6b.tar.gz PROJ-e1edf114105b0f528ef662f79297603617297a6b.zip | |
Allocate PJ* as a C++ object
Diffstat (limited to 'src/malloc.cpp')
| -rw-r--r-- | src/malloc.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/malloc.cpp b/src/malloc.cpp index c8681570..0e80912e 100644 --- a/src/malloc.cpp +++ b/src/malloc.cpp @@ -44,6 +44,8 @@ #include <stdlib.h> #include <string.h> +#include <new> + #include "proj.h" #include "projects.h" @@ -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; } |
